2012-01-15
| 03:34 | bitops | has anyone done any 2D animation with sprite maps in Clojure? any libraries or pointers? |
| 03:35 | amalloy | bitops: just the java ones, i think |
| 03:39 | bitops | amalloy: makes sense...tooling around I've found the clj-processing library. looks like it could be a good one to use. |
| 04:39 | notsonerdysunny | is there a good clojure library to deal with ".zip/.z/.tar.gz/.tar/.gz" files? |
| 04:40 | Raynes | notsonerdysunny: https://github.com/Raynes/fs has some functions for decompressing and unarchiving files. |
| 04:40 | notsonerdysunny | preferably without depending on the system commands.. purely based on JVM stuff.. |
| 04:40 | hiredman | yes |
| 04:40 | Raynes | They are implemented entirely in Clojure backed by core and apache libraries.. None of them shell out. |
| 04:42 | notsonerdysunny | thanks Raynes .. that is exactly what I was looking for. |
| 05:09 | PntBlnk | Hi all, would someone be able to let me know how to structure a macro so that I can use the 'var' special form on an argument? Or is there an example somewhere I could study? Thanks in advance if you can help. |
| 05:13 | amalloy | PntBlnk: i'm not 100% sure what you mean, but binding is the only example i can think of at the moment |
| 05:14 | amalloy | it's a little complicated, though. a simple answer would be (defmacro my-var [x] `(var ~x)), for example |
| 05:14 | PntBlnk | Thanks, I'll have a go... :) |
| 05:15 | PntBlnk | Unfortunately that doesn't work for me. |
| 05:16 | amalloy | that's not really an actionable statement. what did you do; what did you hope would happen; what happened instead? |
| 05:17 | PntBlnk | I've created a modified version of the robert-hooke code with a few extra features, and I'm currently storing hooks as a vector: [target-var <string representation of hook-var that I want to turn to a real var> hook] |
| 05:18 | PntBlnk | So a hook might be [#'korma.core/exec #'my.ns/my-fn #<Atom......>]. |
| 05:20 | PntBlnk | The macro in question is to create the hooks. It works okay, but I'm unhappy that the hook function is currently (.replace (.getName (class f)) \$ \/), which is pretty painful. |
| 05:22 | PntBlnk | The macro takes the target-var and the hook function, and tries to do everything in a syntax-quoted let: `(let [~'fn-var `(var ~~f) ~'fn-atom (atom ~f)](vector ~target-var ~'fn-var ~'fn-atom))) |
| 05:23 | PntBlnk | It's getting the fn-var value which is proving challenging for my tiny noob mind... |
| 05:26 | amalloy | yeah, if you're trying to manage nested syntax-quotes you're just going to be sad overall |
| 05:27 | PntBlnk | I feel very much that way. |
| 05:27 | amalloy | but i don't think you need them, really |
| 05:28 | amalloy | `[~target-var (var ~f) (atom ~f)] is it, right? |
| 05:28 | PntBlnk | Well, var is a special form, and can't be treated like a function... |
| 05:28 | amalloy | that seems to be the less-confused version of what you seem to be trying to do |
| 05:29 | PntBlnk | It is very much nicer, but still doesn't work :) |
| 05:30 | PntBlnk | I get #'my.ns/f .. |
| 05:31 | amalloy | &(let [target-var #'inc, f 'swap!] `[~target-var (var ~f) (atom ~f)] |
| 05:31 | lazybot | java.lang.RuntimeException: EOF while reading, starting at line 1 |
| 05:32 | amalloy | &(let [target-var #'inc, f 'swap!] `[~target-var (var ~f) (atom ~f)]) |
| 05:32 | lazybot | ⇒ [#'clojure.core/inc (var swap!) (clojure.core/atom swap!)] |
| 05:32 | amalloy | point is, you have still not really said what you're doing. you provided a snippet of what you think is the relevant code, but without an idea of how your macro is getting called i can't really write it |
| 05:35 | PntBlnk | Sure. Are you familiar with the robert-hook lib? I'm using a vector to hold the hooks in the form I described earlier. With this code, I can list existing hooks, remove all of them, and will be able to add them to entire namespaces if that's at all useful. |
| 05:36 | amalloy | i know vaguely what robert.hooke does, but nothing about the structure of the lib |
| 05:36 | PntBlnk | The main problem for me was that hooks weren't playing nice when compiling my code. |
| 05:38 | PntBlnk | Aside from the overall functionality my problem is quite simple. I want to store two vars and an atom in a vector. The first var (the target) is fine, because you provide that in #'namespace.qualified/form, but the second is not (unqualified function name), and I'm keen to keep the usage the same as the original code. |
| 05:40 | PntBlnk | The var special form is not available at compile time, so you don't get the same results as in the REPL. |
| 05:40 | amalloy | what do you want an invocation of your macro to look like, and what do you want it to expand to |
| 05:41 | amalloy | those are the important questions. once you have those answered, you generally can write the macro (or determine it's impossible) |
| 05:44 | PntBlnk | Here's one I was playing with before. Fine in the REPL, not so for compilation: (defmacro get-var [f] `(let [~'out (var ~f)] ~'out)) |
| 05:45 | PntBlnk | Hang on... |
| 05:45 | PntBlnk | That appears to work.. |
| 05:46 | PntBlnk | I must apologize as it seems that I have wasted your time! |
| 05:52 | amalloy | happy hunting |
| 05:53 | PntBlnk | Yeah, thanks. Still not getting a final that's done and dusted feeling, but I appreciate the time you spent. Thanks! |
| 06:19 | kaeluka | what's the best way to learn clojure? book/webpage |
| 06:25 | kaeluka | hi, btw ;-) |
| 06:26 | Blkt | good day everyone |
| 06:38 | kaeluka | ..seems pretty empty here, bikt :) |
| 06:56 | augustl | kaeluka: practicing :) |
| 06:57 | augustl | books and writing programs are my favorite ways of practicing |
| 07:00 | kaeluka | but sometimes, a certain web page is better than any book |
| 07:00 | kaeluka | i'm working with stuart halloway's programming clojure for now and maaaan, does this language look nice |
| 07:01 | kaeluka | have been dabbling around a bit a year ago or so but then got distracted |
| 07:19 | augustl | kaeluka: http://www.infoq.com/presentations/Simple-Made-Easy i |
| 07:19 | augustl | err |
| 07:19 | augustl | kaeluka: http://www.infoq.com/presentations/Simple-Made-Easy will also teach you alot about clojure |
| 07:19 | augustl | even though there's no clojure in it :) |
| 07:20 | kaeluka | awesome, great :) |
| 07:22 | kaeluka | btw: what's the editor/IDE most people use for clojure? i would very much like to stick with emacs, does that make sense? |
| 07:24 | augustl | I use emacs at least, but I'm not an authority on clojure ;) |
| 07:24 | raek | kaeluka: a lot of people use emacs for clojure |
| 07:25 | augustl | emacs is good for parens |
| 07:26 | raek | kaeluka: check out the stats :-) http://cemerick.com/2011/07/11/results-of-the-2011-state-of-clojure-survey/ |
| 07:26 | kaeluka | yeah, i'm guessing that paredit mode has to be awesome for clj |
| 07:27 | raek | it is |
| 07:27 | raek | kaeluka: to get started follow the official readmes of clojure-mode (elisp lib) and swank-clojure (clojure lib) |
| 07:27 | raek | https://github.com/technomancy/clojure-mode |
| 07:27 | raek | https://github.com/technomancy/swank-clojure |
| 07:29 | raek | there are a lot outdated tutorials out there, so I just wanted show the correct ones early... |
| 07:30 | kaeluka | yeah, that's why i'm asking |
| 07:30 | kaeluka | thanks a lot! |
| 07:32 | raek | the no 1 cause of problems is having an incompatible version of slime installed in emacs (so beware of that if you come from Common Lisp) |
| 07:33 | raek | anyway, most of the things you need to look out for are explained in the "Troubleshooting" section of the swank-clojure readme |
| 08:15 | kaeluka | raek: no, got no slime installed currently; thanks |
| 08:35 | bpr | is flatten lazy? |
| 09:44 | TimMc | &(take 5 (flatten (range))) |
| 09:44 | lazybot | ⇒ (0 1 2 3 4) |
| 09:44 | TimMc | bpr: ^ |
| 09:55 | raek | ~flatten |
| 09:55 | clojurebot | flatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with. |
| 11:05 | bpr | TimMc, raek: Thanks guys. I actually did wind up using mapcat |
| 11:24 | zzach1 | Compiling clj files with java works using a command line "java -cp clojure.jar:.:classes -Dclojure.compile.path=classes clojure.lang.Compile app.hello ". The resulting class has no debug / line number information. Which option can be used to compile including such information? |
| 11:38 | yoklov | wow. I'm surprised cljs has ``read'' |
| 11:44 | rindolf | Hi all. What's the best way to learn Clojure? |
| 11:45 | pandeiro | rindolf: what's your task? |
| 11:46 | rindolf | pandeiro: I want to learn Clojure in order to learn a new language. |
| 11:46 | rindolf | pandeiro: no direct task, except maybe implementing Golf challenges in Clojure or whatever. |
| 11:46 | pandeiro | but what are you trying to do, specifically? |
| 11:47 | pandeiro | i would once you know the syntax, find code that does things that are somehow related to the problems that interest you |
| 12:08 | mindbender | please how can I get cljs.repl on my project classpath so that I can (require '[cljs.repl :as repl]) without errors |
| 12:09 | mindbender | is there a jar of some sort for clojurescript? |
| 12:11 | ldopa | mindbender: i haven't had any problems using the one from lein-clojurescript |
| 12:11 | ldopa | mindbender: http://clojars.org/org.clojars.bartonj/clojurescript |
| 12:13 | mindbender | ldopa: thanks, I think that's just what I needed |
| 13:51 | yoklov | >:/ code, you and i both know you were running at twice this speed yesterday. |
| 13:59 | yoklov | hrm. how do people profile clojure code? |
| 15:48 | zyfo | Have some noir code that works great on two servers, but when I try to run it locally (lein deps && lein run) I get the following exception: "resource-response does not exist (route.clj)". Any ideas? |
| 16:00 | Guest88848 | Hello, I am new to clojure and would like help using something like (reduce (map reduce +)) on a list of lists of numbers to obtain the sum. |
| 16:00 | Guest88848 | Is this an okay place to ask such questions? |
| 16:01 | _carlos_ | hi! |
| 16:02 | _carlos_ | ,(defn factorial [n] (-> n (+ 1) (range 1) (apply *))) |
| 16:02 | clojurebot | #<Exception java.lang.Exception: SANBOX DENIED> |
| 16:02 | _carlos_ | #(defn factorial [n] (-> n (+ 1) (range 1) (apply *))) |
| 16:02 | _carlos_ | (defn factorial [n] (-> n (+ 1) (range 1) (apply *))); |
| 16:02 | _carlos_ | ._. |
| 16:03 | _carlos_ | do I need to be registered to run code? |
| 16:03 | William_Sharkey | (reduce + 0 (map reduce + 0 '( '(1 2) '(3 4)) )) |
| 16:04 | _carlos_ | anyway, this code doesn't work because ClassCastException clojure.lang.LazySeq cannot be cast to clojure.lang.IFn clojure.core/apply (core.clj:600) |
| 16:04 | William_Sharkey | my code does not work because #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.core$_PLUS_> |
| 16:04 | _carlos_ | I know I should use ->> but I don't understand why the lazy seq doesn't work the oppositte way |
| 16:05 | _carlos_ | William_Sharkey: hahaha.. I thought you were some parrot bot for a minute |
| 16:06 | _carlos_ | William_Sharkey: why do you have 0 as an argument? |
| 16:07 | _carlos_ | William_Sharkey: what do you want to do? |
| 16:07 | raek | William_Sharkey: you probably want (reduce + (apply concat [[1 2] [3 4]])) |
| 16:08 | raek | apply concat turns it into [1 2 3 4] and then you can simply sum that collection |
| 16:09 | _carlos_ | raek: do you know why I can't use first-thread? |
| 16:10 | William_Sharkey | Raek:thank you. |
| 16:10 | William_Sharkey | Carlos: I wanted to sum a list of lists of numbers. |
| 16:11 | raek | William_Sharkey: (map reduce + 0 ...) doesn't make much sense. maybe you wew thinking about something like (map (fn [x] (reduce + 0 x) ...)? |
| 16:12 | raek | _carlos_: the bots don't allow you to define global vars. you can use anonymous functions though |
| 16:12 | raek | _carlos_: ##(let [factorial (fn [n] (-> n (+ 1) (range 1) (apply *)))] (factorial 5)) |
| 16:12 | lazybot | java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn |
| 16:13 | raek | so, the (-> ...) macro expands to this: (apply (range (+ n 1) 1) *) |
| 16:13 | bobhope | Are there any clojure templating libraries? I want to general source code for a different language from a clojure program |
| 16:14 | _carlos_ | bobhope: I heard about fleet |
| 16:14 | raek | _carlos_: can you write the function body without ->? |
| 16:15 | _carlos_ | raek: I can write with ->> last-thread macro, but I wanted to understand why it doesn't work with first-thread ->. for me both make sense |
| 16:16 | raek | well, they don't mean the same thing |
| 16:16 | raek | _carlos_: do you know about the difference? |
| 16:16 | _carlos_ | raek: yes, I know, but both directions make sense from substitution point of view |
| 16:16 | raek | what does (apply (range (+ n 1) 1) *) mean? |
| 16:17 | raek | lets assume n = 5 |
| 16:17 | raek | (apply (range (+ 5 1) 1) *) |
| 16:17 | raek | (apply (range 6 1) *) |
| 16:17 | raek | (apply () *) |
| 16:17 | raek | BOOM |
| 16:17 | bobhope | _carlos_, fleet seems interesting, but it seems like they only designed for xml-esque languages |
| 16:17 | raek | () is not a function |
| 16:18 | raek | so to me the (-> ...) version does not make sence, since the functions end up with the arguments in the wrong order |
| 16:19 | _carlos_ | raek: n is applied as last argument of (+ 1), making it (+ 1 n), not (+ n 1) |
| 16:20 | raek | _carlos_: yes, since (+ a b) is equal to (+ b a) this is not a problem. |
| 16:20 | raek | _carlos_: but what about the call to 'range' and 'apply'? |
| 16:20 | _carlos_ | raek: ha, sorry, just a sec |
| 16:23 | _carlos_ | raek: why did you apply the result of (+ 5 1) to the first argument of range? range also takes the result in its last argument |
| 16:23 | raek | _carlos_: I'm innocent! -> did it :-) |
| 16:24 | raek | _carlos_: the -> macro rewrites the code in a fixed pattern. it knowns nothing about what the different argument means |
| 16:25 | _carlos_ | raek: my bias was that is was putting it in the end of the expression. my bad! thank you very much |
| 16:26 | raek | think of -> as a transformation that turns (-> a (b0 b1 b2 ... bn) ...more...) into (-> (b0 a b1 b2 ... bn) ...more...) |
| 16:26 | raek | and (-> a) into a |
| 16:27 | _carlos_ | raek: I understand your previous example step by step eval.. my bad :-) |
| 16:50 | _carlos_ | is it just me or most times clojure code is easier to read in a one liner than broken into several lines like most books do? |
| 16:52 | jodaro | clojure.main quit unexpectedly while using the jna8943583805303982763.tmp plug-in. |
| 16:52 | jodaro | woopsie |
| 16:56 | brehaut | _carlos_: just you? |
| 16:57 | Raynes | Spaces are stupid too! (foo,bar(baz),(foo,bar)) |
| 16:57 | brehaut | Raynes: why have you used such long winded symbols? |
| 16:57 | Raynes | Bah! |
| 16:58 | raek | Raynes: you use commas for indentation too? :P |
| 16:58 | Raynes | raek: Of course. |
| 16:59 | raek | does someone know how to turn off the "fn" to "ƒ" transformation that emacs starter kit has by default? |
| 17:00 | raek | maybe I could just comment out these lines in my checkout: https://github.com/scgilardi/emacs-starter-kit/blob/5937360cc91d352380d95801d1a0cebecfb47d96/modules/starter-kit-lisp.el#L85 |
| 17:01 | _carlos_ | if computer languages supported more expressive symbols, variables could be, say chinese characters. code would be much more compact |
| 17:02 | raek | clojure does not forbid them |
| 17:02 | _carlos_ | raek: really? didn't know |
| 17:03 | brehaut | ,'ß |
| 17:03 | clojurebot | ß |
| 17:04 | brehaut | ,((fn [ß] (inc ß)) 1) |
| 17:04 | clojurebot | 2 |
| 17:04 | raek | it isn't really set in stone which characters are allowed, but alphanumeric characters (even non-ascii ones) are ok |
| 17:05 | brehaut | raek: although clojure.org says "Symbols begin with a non-numeric character and can contain alphanumeric characters and *, +, !, -, _, and ? (other characters will be allowed eventually, but not all macro characters have been determined)" |
| 17:05 | _carlos_ | ,((fn [世界] (inc 世界)) 1) |
| 17:05 | clojurebot | 2 |
| 17:05 | _carlos_ | :o |
| 17:06 | brehaut | _carlos_ please dont write apljure now! |
| 17:06 | raek | .clj-files are always in UTF-8, so all unicode characters can be used in clojure source code |
| 17:06 | _carlos_ | haha |
| 17:09 | brehaut | raek: yeah sorry. i understand that, i was just mentioning that if you read clojure.org, you might get a different idea |
| 17:10 | brehaut | raek: rather than trying to contradict you |
| 17:13 | amalloy | raek: .clj files are required to be UTF-8? |
| 17:15 | raek | amalloy: I'm pretty sure that clojure will always decode them using UTF-8, but maybe I should try to back up my claim |
| 17:17 | raek | https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L6870 |
| 17:18 | raek | there |
| 17:19 | amalloy | interesting. that means someone whose OS uses a different encoding by default will be unable to compile their files |
| 17:19 | raek | amalloy: how? |
| 17:19 | brehaut | amalloy: you mean e.g. windows and UCS16 ? |
| 17:20 | raek | OS'es do not transcode dat just like that |
| 17:20 | raek | *data |
| 17:21 | raek | OS'es often have some notions of default encodings, but that doesn't affect much |
| 17:21 | _carlos_ | from what I see, if my file is encoded with a different encoding, it will blow |
| 17:21 | amalloy | well. not an area i'm an expert in, but it seems like if i open up a new text file using some japanese character-encoding, then any characters which aren't encoded the same as UTF8 will be read incorrectly |
| 17:22 | raek | yes. this is an issue the text editor deals with rather than the OS |
| 17:22 | brehaut | oh. UCS-2 sorry |
| 17:22 | bobhope | What is the difference between extends? and satisfies? for protocols? |
| 17:22 | _carlos_ | raek: so a language plugin for the editor, detecting the target language would always try to force that encoding |
| 17:22 | raek | and since the encoding is not actually stored anywhere, a text editor can only guess the encoding |
| 17:23 | brehaut | ,(doc satisfies?) |
| 17:23 | clojurebot | "([protocol x]); Returns true if x satisfies the protocol" |
| 17:23 | raek | bobhope: check on a instance vs a class I think |
| 17:24 | _carlos_ | raek: based on the extension would by concept be enough to guess de decoder |
| 17:24 | _carlos_ | *the decoder |
| 17:24 | bobhope | raek, thanks |
| 17:24 | bobhope | that seems like a reason to have both |
| 17:24 | raek | _carlos_: yes, for some text-based formats (e.g. Clojure source files and JSON files) that is true |
| 17:25 | raek | but most text-based formats are broken and do not specify an encoding or lets the user choose but does not provite any way of soting that choice |
| 17:27 | raek | *provide *storing |
| 17:29 | bobhope | If I want to export a bunch of vars from another namespace when my namespace is imported, should I use ns-utils/immigrate? |
| 17:31 | raek | bobhope: there is no perfect way of doing that in clojure |
| 17:31 | bobhope | Here's my scenario |
| 17:32 | bobhope | I want to provide a different numeric tower, so I want to use clojure.algos.generic +-*/ |
| 17:32 | bobhope | but make it so that anyone who includes my library will see those exposed to them as well |
| 17:32 | bobhope | and they could even add their own extensions to those multimethods |
| 17:32 | bobhope | how should I do this? |
| 17:32 | raek | if you use immigrate and redefine the vars in the source namespace, they won't be updated in the namespace into which they were immigrated |
| 17:33 | bobhope | I'd be happy to cut & paste the code from clojure.algos.generic into my project and call it a day |
| 17:33 | bobhope | is immigrate that functionality? |
| 17:34 | bobhope | and is immigrate in clojure 1.3? It looked like it was only in the monolithic contrib |
| 17:34 | raek | bobhope: it is in monolithic contrib, i.e. not in 1.3 |
| 17:35 | raek | http://dev.clojure.org/display/doc/FAQ |
| 17:35 | bobhope | raek, can I use monolithic contrib and some clojure contrib 1.3 stuff? |
| 17:35 | bobhope | I've never tried |
| 17:35 | raek | "How can I make a namespace A that "exports" all the public symbols from namespaces B and C?" |
| 17:35 | brehaut | bobhope: i think its possible yes, if you dont mind a screed of warnings |
| 17:36 | raek | bobhope: no. there won't be any monolithic contrib for clojure 1.3. (and the one from 1.2 won't work in 1.3) |
| 17:36 | bobhope | Ok, I'll probably just reimplement the numeric tower the way I want it then |
| 17:36 | bobhope | back to basics :) |
| 17:37 | brehaut | ah. its possible to use monolithic contrib with new contrib in 1.2 |
| 17:38 | raek | yes. the new contrib libs are usually version independent. (some parts of monolithic aren't therefore monolithic as a whole isn't) |
| 17:39 | raek | bobhope: immigrate is pretty small, so if you really need to use it it's probably easier to just copy and paste it into your own code |
| 17:42 | amro | hi |
| 17:42 | amro | I seem to have broken lein |
| 17:43 | amro | Exception in thread "main" java.lang.NoClassDefFoundError: clojure.core.protocols$fn__5393 |
| 17:43 | amro | this after I installed some java stuff |
| 17:43 | amro | I'm not sure exactly what, I installed a few while trying to get jni.h |
| 17:45 | mrevil | i there a way to set different environment variables when I running tests as opposed to development a environment? I need to control which database my noir tests connect to. How do I determine that code is being executed in the context of a test or swank? Ruby on Rails has 3 environments with different initialization scripts, is there something similar pre-baked into noir, clojure.test or midje? |
| 17:48 | clj_newb | are variables that start with _ reserved by clojure? |
| 17:48 | clj_newb | like _foo ? |
| 17:49 | raek | amro: are there files in your classes/ directory? if so, have you tried deleting them? |
| 17:49 | raek | sounds like you have old ahead of time compiled code lying around |
| 17:49 | brehaut | clj_newb: ive never seen that in clojure code. do you have an example? |
| 17:49 | clj_newb | I want to define something like _Animal |
| 17:49 | clj_newb | which is a wrapper around Animal. |
| 17:49 | clj_newb | where Animal is a defrecord. |
| 17:50 | Raynes | There is nothing special about underscores. That said, what you want to do is nuts. |
| 17:50 | clj_newb | Raynes: why? |
| 17:51 | brehaut | to start with, why do you want a wrapper? |
| 17:51 | clj_newb | styptype checking |
| 17:51 | Raynes | Because Clojure isn't Perl. We like to use words instead of symbols. |
| 17:51 | brehaut | styptype? |
| 17:51 | clj_newb | *type checking* |
| 17:52 | brehaut | clojure is a dynamic language; type checking is not idiomatic |
| 17:53 | jodaro | so i'm looking at clojure.tools.logging |
| 17:53 | clj_newb | brehaut: I have never been able to write more than 10K LOC w/o typing. |
| 17:53 | clj_newb | brehaut: Is there a list of good practices of "writing largescale clojure apps" ? |
| 17:53 | bobhope | test your code |
| 17:53 | bobhope | with unit tests |
| 17:53 | bobhope | and automated tests |
| 17:53 | jodaro | in (defn log*, there is a line about using agents |
| 17:53 | amro | raek: I broke lein in general- it doesn't work at all |
| 17:54 | bobhope | if your testing consists of running examples in a repl, or anything done by hand, it's called "experimentation", not testing |
| 17:54 | bobhope | ;) |
| 17:54 | jodaro | and it says "for performance reasons, an agent will only be used when invoked within a running transaction ..." |
| 17:54 | brehaut | clj_newb: write small, pure functions that can be easily reasoned about |
| 17:54 | jodaro | is it particularly expensive to use send-off? |
| 17:54 | brehaut | clj_newb: and leverage HoFs to not write as much code |
| 17:56 | clj_newb | what is HoFs ? |
| 17:56 | brehaut | clj_newb: higher order functions |
| 17:56 | brehaut | map being a classic example |
| 17:56 | clj_newb | yeah; I think the problem is that I'm writing to write haskell in clojure |
| 17:59 | amalloy | hiredman: i have a terrible suspicion that Keyword was made non-final because it now contains non-final fields. those two things obviously shouldn't be related, but it's quite a coincidence otherwise |
| 18:03 | blakesmith | Is there an idiom to do the following more concisely? |
| 18:03 | blakesmith | &(map (fn [x y] [x y]) (range 10) (range 10)) |
| 18:03 | lazybot | ⇒ ([0 0] [1 1] [2 2] [3 3] [4 4] [5 5] [6 6] [7 7] [8 8] [9 9]) |
| 18:03 | brehaut | (map vector … |
| 18:04 | blakesmith | Oh, neato. |
| 18:04 | blakesmith | Since vector takes variable arguments... |
| 18:05 | blakesmith | Sweet, thanks! |
| 18:05 | blakesmith | Er, variable argument length. |
| 18:33 | Raynes | brehaut: ohai |
| 18:33 | brehaut | Raynes: hello |
| 18:33 | Raynes | brehaut: Feel like testing my Vim plugin for me? |
| 18:33 | brehaut | Raynes: haha |
| 18:34 | Raynes | >_> |
| 18:34 | brehaut | Raynes: i dont know how to use vim |
| 18:34 | Raynes | Oh, I thought you were a vimmer. |
| 18:34 | brehaut | Raynes: nope. just a pot stirrer |
| 18:34 | Raynes | Heh |
| 18:34 | brehaut | i dislike all text editors :P |
| 18:34 | Raynes | :) |
| 18:34 | brehaut | just happen to dislike some less than others |
| 18:34 | Raynes | It's unfortunate that I know so few vimmers. |
| 18:35 | Raynes | But then again, I couldn't even get Emacsers to test my elisp when I wrote it. |
| 18:35 | Raynes | *cough* technomancy *cough* |
| 18:38 | guns | Raynes: I'm in the process of streamlining my vim/clojure workflow. I wouldn't mind beta testing your software |
| 18:39 | Raynes | guns: It's at https://github.com/Raynes/refheap.vim if you want to give it a go. |
| 18:40 | Raynes | Haha |
| 18:41 | technomancy | also, I wish the word "infidel" could be used more without bringing religious connotations into it |
| 18:41 | technomancy | it's a pretty good word. |
| 18:41 | Raynes | technomancy: ARE YOU SAYING MY GOD IS FAKE? |
| 18:42 | guns | Raynes: You may want to leverage the `autoload` plugin method to avoid load errors at startup |
| 18:42 | brehaut | Raynes: not fake, just old fashioned and not self hosting |
| 18:43 | technomancy | what; no, I'm not saying anything... let's just meet on Mt. Caramel with some altars and see whose gets lit. |
| 18:43 | Raynes | guns: I have no clue what autoload is. |
| 18:43 | guns | Raynes: it's vim's lazy plugin loading system |
| 18:44 | guns | Gundo.vim is a pretty good example of a python plugin that employs autoload |
| 18:45 | Raynes | guns: It looks like I'd basically just put my stuff that checks if Python is loaded and my command! statement in the plugin stuff and the rest in autoload. |
| 18:45 | guns | Raynes: yep. also, how to install pyperclip.py ? |
| 18:46 | Raynes | You don't need pyperclip. Why did you think you needed that? :o |
| 18:46 | Raynes | Oh man, did I include that? |
| 18:46 | guns | line 33: |
| 18:46 | guns | Traceback (most recent call last): |
| 18:46 | guns | File "<string>", line 1, in <module> |
| 18:46 | guns | IOError: [Errno 2] No such file or directory: 'pyperclip.py' |
| 18:46 | clojurebot | Titim gan éirí ort. |
| 18:47 | Raynes | guns: That's an accidental commit. Hold on. |
| 18:49 | Raynes | guns: Pull again. Sorry, I forgot to commit some stuff (and accidentally committed other stuff). |
| 18:51 | guns | Got a 413 (request too large) when trying to post ~24k lines (unicode table). Also, is refheap hosted on your server? |
| 18:51 | guns | I suppose that's reasonable (too many lineS) |
| 18:52 | technomancy | as long as you don't get 418 when trying to upload coffeescript |
| 18:52 | guns | haha. had to look that one up |
| 18:53 | Raynes | guns: Yes, refheap is hosted on my server. |
| 18:54 | Raynes | guns: Also, I guess the server doesn't like large requests. I have the maximum paste size capped at like 60KB, but this error wasn't because of that. |
| 18:55 | guns | Raynes: it's not really your problem, but pbcopy/pbpaste is broken from within Tmux sessions. I get around that myself by using a clipboard plugin for rxvt-unicode |
| 18:56 | guns | I'm not sure of a good way to solve it from your perspective though |
| 18:56 | Raynes | It's a pain in the ass to copy stuff programmatically and have it work everywhere. |
| 18:56 | Raynes | You can still copy the link though, at least. |
| 18:56 | emezeske | guns: what is pbcopy? |
| 18:57 | guns | emezeske: xclip for OS X |
| 18:57 | guns | basically |
| 18:57 | emezeske | ahh, gotcha |
| 18:57 | emezeske | I was gonna suggest xclip :P |
| 18:57 | Raynes | guns: How large is your unicode table? In bytes. |
| 18:58 | guns | 966360 bytes |
| 18:59 | technomancy | emezeske: hey, is there any specific reason you're publishing lein-cljsbuild using the emezeske group-id? |
| 18:59 | Raynes | guns: Yeah, that'd be way over what refheap is designed to accept. nginx is probably rejecting it before it even gets to me though. |
| 18:59 | guns | Raynes: :) I was just stress testing |
| 19:00 | Raynes | :) |
| 19:01 | guns | Otherwise, it all works quite well, visual selections and all. I would autoload, though, for people that move their .vim setup to different machines and don't want to easy_install * for every unix account |
| 19:01 | Raynes | Yeah, I agree. I just didn't know about it until now. I'll definitely do that in a bit. |
| 19:01 | Raynes | Thanks a lot for testing it. |
| 19:01 | guns | np |
| 19:01 | Raynes | Clojurians vimmers are a rare breed. |
| 19:08 | oakwise | Raynes: I'm one, but I just started down the dark road to emacs today |
| 19:08 | oakwise | the propaganda got to me |
| 19:08 | Raynes | Heh. |
| 19:08 | Raynes | I'm actually a big Emacs fan. I'm just currently experimenting with other editors. |
| 19:08 | Raynes | Which is good, since somebody had to write plugins for them for refheap. |
| 19:09 | technomancy | and pillage them for their good ideas? |
| 19:10 | emezeske | technomancy: no specific reason other than... I don't know what I'm doing? :) |
| 19:10 | Raynes | technomancy: Vim has a lot of good ideas. VimL isn't one of them. |
| 19:10 | emezeske | technomancy: is there a preferred way to do that? |
| 19:11 | guns | Haha. Vimscript is a real drop kick. It does have a map() fn, fwiw. no reduce though. |
| 19:11 | oakwise | Raynes: "It's a pain in the ass to copy stuff programmatically and have it work everywhere" <-- does the * register not work? |
| 19:11 | guns | oakwise: OS X doesn't use X SELECTION or CLIPBOARD |
| 19:12 | technomancy | emezeske: heh; sure, it's conventional to just specify lein-cljsbuild, which ends up setting the group-id to the same as the artifact-id |
| 19:12 | guns | pbcopy is the workaround for OS X, but not for people who use X on OS X (like me) |
| 19:12 | oakwise | "*y works for me on osx |
| 19:12 | emezeske | technomancy: ahh, I did not know that |
| 19:13 | technomancy | emezeske: actually I just brushed up the plugin guide for Leiningen 2.0; I would love to hear your feedback on it since you're coming at it from a fresh perspective |
| 19:13 | guns | oakwise: what terminal and what vim, I'm curious |
| 19:13 | guns | ? |
| 19:13 | technomancy | https://github.com/technomancy/leiningen/blob/master/doc/PLUGINS.md if you get the chance |
| 19:13 | oakwise | guns: I used to use pbcopy/xsel scripty workarounds, but * seems to work on my platforms now |
| 19:13 | emezeske | technomancy: I'll definitely take a look, probably sometime today or tomorrow |
| 19:13 | oakwise | iterm and... |
| 19:14 | emezeske | technomancy: so, lein-cljsbuild depends on emezeske/clojurescript and emezeske/closure-library. should those be self-group-id'ed as well? |
| 19:14 | oakwise | guns: vim 7.3 |
| 19:14 | Raynes | oakwise, guns: I couldn't find a way to use Vim stuff to copy text that was obtained from an http response. Black magic. |
| 19:14 | emezeske | technomancy: or does that matter? |
| 19:14 | guns | Oh, I see. The iTerm devs are pretty hardworking |
| 19:14 | technomancy | emezeske: no, if it's a library you didn't write then it's important *not* to have the group-id match the artifact-id |
| 19:14 | guns | they just added a bunch of tmux support I heard |
| 19:15 | emezeske | technomancy: interesting, okay |
| 19:15 | technomancy | org.clojars.emezeske is more common, but plain emezeske is fine too. |
| 19:15 | emezeske | technomancy: cool, thanks |
| 19:15 | technomancy | emezeske: if you read TUTORIAL.md in the same directory as PLUGINS.md, it covers those questions too =) |
| 19:15 | oakwise | guns: I just tried it in Terminal and it works fine |
| 19:15 | emezeske | technomancy: so, having the group-id match the artifact-id is used to indicate the "canonical" source? |
| 19:15 | emezeske | technomancy: awesome! |
| 19:15 | technomancy | emezeske: zactly |
| 19:16 | guns | oakwise: /usr/bin/vim, and my copy of vim don't work that way |
| 19:16 | guns | oakwise: do you compile with --with-darwin? |
| 19:16 | technomancy | emezeske: so there are a handful of things in those docs that only apply to leiningen 2, but for the most part it will apply to 1.x |
| 19:16 | guns | I use --without-darwin, so that's probably my problem |
| 19:17 | emezeske | technomancy: okay |
| 19:17 | oakwise | guns: I think I may have compiled from source to get ruby support. Don't remember the flags. |
| 19:19 | guns | oakwise: Yeah, they must have added OS X pasteboard support in the past couple of years. I switched to rxvt-unicode and started compiling vim without mac-specific features |
| 19:19 | guns | But then in my case, Raynes could still use the "* or "+ register to copy into my system clipboard |
| 19:20 | guns | so perhaps you are right |
| 19:20 | Raynes | Hrm. |
| 19:21 | technomancy | emezeske: I spent a few hours playing with cljs-one on Friday and most of it was spent wishing it used something like lein-cljsbuild =) |
| 19:22 | emezeske | technomancy: haha, I wonder if I should ping those people to see if there's some way to coordinate |
| 19:23 | technomancy | I don't expect they would be particularly receptive. |
| 19:23 | technomancy | https://github.com/brentonashworth/one/issues/64 |
| 19:25 | technomancy | when I talked to Stu H at the conj he mentioned that he still doesn't use Leiningen in some cases because he thought it was lacking some basic feature that had been implemented since 1.1.0 or so. |
| 19:25 | emezeske | technomancy: I did not know about checkout dependencies |
| 19:25 | emezeske | yikes! |
| 19:25 | emezeske | knowing about checkout deps is going to make my life easier |
| 19:26 | ibdknox | emezeske: I'm with technomancy, I'm not sure you'll get very far with them :( |
| 19:26 | oakwise | Raynes: vim.command("let @* = %r" % res) |
| 19:26 | oakwise | that should replace the need for xerox I think |
| 19:26 | oakwise | although you may have to do some escaping (?) |
| 19:27 | ibdknox | they seem to like to reimplement things I've built :p |
| 19:27 | emezeske | heh |
| 19:27 | oakwise | guns: what does without-darwin get you? |
| 19:27 | emezeske | ibdknox: I kinda did that too with cljs-watch vs lein-cljsbuild :P |
| 19:27 | guns | oakwise: better X integration |
| 19:27 | emezeske | ibdknox: don't hate me! |
| 19:28 | ibdknox | emezeske: quite the opposite, I was being lazy and waiting for lein 2.0 before I did anything, now I don't have to :) |
| 19:28 | guns | Raynes: remember, too that /usr/bin/vim on Lion is *not* compiled with "* or "+ registers, so you'll still need the pbcopy stuff |
| 19:28 | emezeske | ibdknox: haha, nice |
| 19:29 | Raynes | guns: Yeah, it seems like using xerox is the more general way to go here. |
| 19:29 | ibdknox | I'll probably resurrect noir-cljs as soon as an official clojurescript goes up somewhere |
| 19:29 | oakwise | ah my bad |
| 19:29 | emezeske | yeah, official cljs would be nice |
| 19:49 | seancorfield | emezeske: i installed cljsbuild 0.0.4 as a global plugin and started to see AOT version compatibility errors - i didn't spend time tracking it down, just uninstalled the plugin (and will try again with a dev-dependencies entry) - just mentioning it as an FYI |
| 19:50 | technomancy | 0.0.4? that's old news, man |
| 19:50 | emezeske | seancorfield: yeah, cljsbuild (not lein-cljsbuild) is super broken |
| 19:51 | emezeske | there's a bug in the clojure compiler that does not save the :macro metadata in class files |
| 19:51 | seancorfield | i meant lein-cljsbuild - i was just being lazy typing |
| 19:51 | emezeske | ah, gotcha, there was actually a non-lein version for a while (that I wish I could eradicate) |
| 19:51 | seancorfield | 0.0.4 was emezeske/lein-cljsbuild - nice to see you've switch to just lein-cljsbuild |
| 19:52 | emezeske | I'll mess around with the global-plugin way and see if I can repro |
| 19:52 | emezeske | I'd guess that the problem is the same as I mentioned (:macro metadata) |
| 19:52 | emezeske | Unfortunately, it means that the clojurescript compiler cannot be AOTed. Well, it can, but it will not work correctly |
| 19:53 | notsonerdysunny | Is there a way to have stacktrace at the time error display the whole thing instead of it cutting it at some point because it is too large.. |
| 19:54 | seancorfield | fwiw, it doesn't seem to happen with 0.0.6 as a global plugin |
| 19:55 | technomancy | emezeske: is it this bug? http://dev.clojure.org/jira/browse/CLJ-130 |
| 19:55 | technomancy | that's been driving me crazy since forever. |
| 19:55 | seancorfield | i just installed that and fired up a new swank / slime repl and ran the test that failed before and it didn't fall over :) |
| 19:55 | technomancy | I think the official line is "it will be fixed in the clojure-in-clojure compiler" =\ |
| 19:57 | emezeske | technomancy: very well could be |
| 19:57 | emezeske | seancorfield: awesome, thanks for trying it! |
| 20:00 | seancorfield | it'll be a while before i can really spend some time with it... i need to experiment with integrating with fw/1 at some point |
| 20:01 | seancorfield | but work's keeping me a bit too busy and we're not using clj for web front end stuff (yet) |
| 20:01 | emezeske | seancorfield: I created https://github.com/emezeske/lein-cljsbuild/issues/10 |
| 20:01 | emezeske | seancorfield: if you come across any more AOT weirdness, please note it there |
| 20:02 | emezeske | hopefully, the problem will just never come back :) |
| 20:04 | ibdknox | I really don't understand the argument against distributing cljs libs through maven |
| 20:05 | hiredman | rich has some kind of objection to the forcing of a linear progression of versions on to a project (at least from what I hear) |
| 20:06 | hiredman | which is part of maven's model I guess |
| 20:06 | ibdknox | people can version things however they want? |
| 20:06 | ibdknox | it can be a tree |
| 20:06 | ibdknox | lol |
| 20:06 | hiredman | sure, but the way maven versions things doesn't account for a tree |
| 20:07 | ibdknox | yeah. Is there some versioning scheme that does? |
| 20:07 | hiredman | I am not sure really, I know he mentioned "maven tradeoffs" on the mailing list at one point, not sure if he ever elaborated on that |
| 20:07 | hiredman | (I think I responded asking for clarification, but I am still in the dark) |
| 20:09 | hiredman | https://github.com/clojure/clojure/commit/59d3c724684c212fbb5eafaaaac30761c2c75a37 speaking of things I am in the dark about |
| 20:10 | ibdknox | oh weird |
| 20:16 | ibdknox | hiredman: there used to be a big performance gain with final classes, do you know if that's still the case? |
| 20:17 | hiredman | I don't |
| 21:26 | lynaghk | Does anyone know a clean way to check the arity of anonymous functions? |
| 21:26 | lynaghk | Preferably that works in ClojureScript. |
| 21:27 | brehaut | this is a guess, but unless there is metadata that tells you, there is probably no way to check arity of a clojurescript function, because there is no way to check the arity of a javascript function |
| 21:27 | lynaghk | Yeah, I was thinking that too |
| 21:27 | ibdknox | and functions don't have metadata in CLJS :( |
| 21:28 | lynaghk | I don't actually need the arity, I just need the more JavaScripty behavior of passing lots of args to functions with impunity |
| 21:28 | ibdknox | hm? |
| 21:28 | lynaghk | Basically, let (#(vector %) 1 2 3 4 5) eval to [1] happily |
| 21:29 | ibdknox | (first %&) |
| 21:29 | lynaghk | Chris, this is for an implementation of D3, actually. |
| 21:29 | lynaghk | I'm hoping I can let people write {:x #(whatever %)} |
| 21:30 | lynaghk | instead of having to always catch both the datum and the index; {:x (fn [d idx] (whatever d))} |
| 21:30 | ibdknox | ah |
| 21:30 | ibdknox | cljs let's you do that for free |
| 21:30 | ibdknox | by accident |
| 21:30 | ibdknox | unless that changed recently |
| 21:31 | lynaghk | oh |
| 21:31 | lynaghk | I was testing in a CLJ repl |
| 21:31 | lynaghk | go figure. |
| 21:31 | ibdknox | by virtue of the JS function implementation |
| 21:31 | ibdknox | you can pass in as many as you want |
| 21:31 | ibdknox | and they just get ignored |
| 21:32 | lynaghk | Sounds like some JS permissiveness is leaking into our glorious semantics. |
| 21:32 | ibdknox | one of the many subtle differences between CLJ and CLJS lol |
| 21:32 | technomancy | lynaghk: it used to work in 1.2; IIRC I opened an issue on that |
| 21:32 | technomancy | I'll let you guess what happened to the issue |
| 21:32 | ibdknox | heh |
| 21:32 | brehaut | technomancy: it was promptly fixed and closed |
| 21:32 | brehaut | amirite? |
| 21:32 | ibdknox | ~guards |
| 21:32 | clojurebot | SEIZE HIM! |
| 21:32 | lynaghk | I mean, I can see how arity checking of anon functions is a feature. |
| 21:33 | technomancy | it could be that it's something planned for the "dynamicity knobs" |
| 21:33 | lynaghk | It makes sense in most cases; just this particular one where I'm expecting users to pass 'em in. |
| 21:33 | ibdknox | lynaghk: yeah I just checked, that's what I did for my D3 clone |
| 21:33 | ibdknox | and it seems to work |
| 21:33 | brehaut | what is D3? |
| 21:34 | lynaghk | For future-proof-ness and a clear indicator that it's a gross situation I might just do some try/catches. |
| 21:34 | lynaghk | It's a DOM manipulation library focused on mapping abstract data to DOM elements. |
| 21:34 | ibdknox | brehaut: http://mbostock.github.com/d3/ |
| 21:34 | ibdknox | very cool stuff |
| 21:34 | ibdknox | you can make really neat visualizations in it |
| 21:34 | brehaut | oh! ive seen this. its very cool |
| 21:35 | ibdknox | there's a simple CLJS implementation of it in pinot |
| 21:35 | technomancy | I really wish we'd hear more about the plans for dynamicity knobs |
| 21:35 | technomancy | since it also seems to be blocking locals-clearing, which is needed for good debuggers |
| 21:35 | ibdknox | technomancy: I really wish we'd hear more about plans. |
| 21:35 | ibdknox | :) |
| 21:36 | ibdknox | brehaut: a mere 77 lines! https://github.com/ibdknox/pinot/blob/master/src/pinot/draw/visualization.cljs |
| 21:37 | lynaghk | The basic idea of D3 is pretty simple, yeah. Clojure's conciseness surely doesn't hurt either |
| 21:37 | brehaut | ibdknox: nice :) |
| 21:37 | lynaghk | I'm working on a D3-like library in Clojure(Script), and for a lot of visualizations the compiled JavaScript (including the cljs runtime) is half the size of minified d3.js |
| 21:38 | ibdknox | lol |
| 21:38 | lynaghk | Then again, Bostock's library has a TON of great layouts, scales, &c. |
| 21:39 | lynaghk | That's one of the nice things about Closure though; no need to worry about library bloat. |
| 21:39 | brehaut | D3 is the successor to a similar library right? |
| 21:39 | lynaghk | Protovis was Bostock's earlier project |
| 21:39 | brehaut | thats the one |
| 21:39 | lynaghk | it had a custom scenegraph implementation, which made it somewhat hard to debug. |
| 21:40 | lynaghk | ibdknox, do you have any tips for writing Clojure targeting both cljs and the jvm? |
| 21:41 | emezeske | lynaghk: you can't do exceptions AFAICT |
| 21:41 | lynaghk | If I do this try/catch hack around the arity, I'm not sure how to try to catch both kinds of errors without angering the runtimes. |
| 21:41 | emezeske | lynaghk: also, macros are very tricky to share |
| 21:41 | lynaghk | I think you can catch errors in cljs, they're all just js/Error. |
| 21:42 | ibdknox | my suggestion would be to write it for Clojure first, then worry about CLJS |
| 21:42 | ibdknox | in terms of error handling |
| 21:42 | ibdknox | the best thing to do is probably to create your own macro that you then use everywhere |
| 21:42 | ibdknox | and swap a single specific file out for each impl |
| 21:42 | lynaghk | mm, that makes sense |
| 21:42 | ibdknox | basically hide the differences in one file that changes and go from there |
| 21:43 | ibdknox | otherwise it will be painful :( |
| 22:17 | devn | a leaderboard in clojure -- ref or atom? |
| 22:17 | devn | sorted-map or sorted-set? |
| 23:30 | devn | is it possible to create a ref using sorted-set-by and have it continue to sort as items are conj'd onto the map? |
| 23:30 | devn | onto the set* |
| 23:32 | devn | it doesn't appear so. |
| 23:35 | ibdknox | why would it being in a ref make a difference? |
| 23:36 | devn | idk -- but it doesn't seem to retain its sorting |
| 23:37 | ibdknox | hm |
| 23:37 | ibdknox | it worked for me? |
| 23:39 | ibdknox | ,(let [r (ref (sorted-set-by >))] (dosync (alter r conj 4)) (dosync (alter r conj 1)) (dosync alter r conj 2)) |
| 23:39 | clojurebot | 2 |
| 23:39 | ibdknox | lol |
| 23:39 | ibdknox | ,(let [r (ref (sorted-set-by >))] (dosync (alter r conj 4)) (dosync (alter r conj 1)) (dosync alter r conj 2) @r) |
| 23:39 | clojurebot | #{4 1} |
| 23:40 | ibdknox | I shouldn't type code in IRC |
| 23:40 | ibdknox | ,(let [r (ref (sorted-set-by >))] (dosync (alter r conj 4)) (dosync (alter r conj 1)) (dosync (alter r conj 2)) @r) |
| 23:40 | clojurebot | #{4 2 1} |
| 23:42 | devn | hm -- wonder what I'm doing wrong here |
| 23:43 | devn | ibdknox: how about when conjing maps? |
| 23:43 | amalloy | devn: do it without refs, and then add refs in once you have it working. there is no way the refs are relevant |
| 23:43 | ibdknox | devn: ^ |
| 23:44 | amalloy | then, if it works without refs but not with them, re-inspect how you added them, cause that'll be the part you did wrong |
| 23:44 | devn | fair enough -- im rewriting this anyway |
| 23:44 | devn | i made a mess |
| 23:45 | amalloy | ibdknox: i liked your broken examples, though. definitely an error it's easy to make *and* easy to miss proofreading |
| 23:46 | ibdknox | yeah that last one is kinda scary |
| 23:47 | ibdknox | hadn't really thought about the fact that that would just fail silently |
| 23:50 | amalloy | ibdknox: proposed awful solution: (defmacro dosync [first & more] (if (coll? first) `(dosync* (do ~first ~@more)) `(dosync* (~first ~@more)))) |
| 23:51 | ibdknox | lol |