#clojure log - Jul 29 2011

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:15 jcromartie: rock on

0:16 Pupeno: Good morning.

0:24 jcromartie: that reminds me... it's time to go to bed

0:44 Pupeno: What's the best way to run Clojure tests in Emacs? I'm using Slime.

0:56 scottj: Pupeno: I don't know but there's clojure-test-mode so you can C-c t I think to go from code to tests and C-c C-, maybe to run the tests and have failing ones highlighted

0:56 jcromartie: yeah

0:56 that's the way to go

0:57 so I said to myself "hey it would be cool to have a really dead simple CMS/string-management/localization as part of this app"

0:57 middleware!

0:57 (wrap-localization)

0:58 which replaces $foo$ in the body of the response with the localized string for key "foo"

1:31 except, $ doesn't work with the nice replace in str-utils2 !

1:31 it complains of an invalid group

1:32 nah nevermind

2:25 laker: hello, what's clojure's answer to heavy client concurrency, is 1 agent per client a reasonable option?

2:47 dsantiago: Is there an easy way to take a namespace like "a.b.c-d" and have that be converted to a file path that clojure would look for, like "a/b/c_d"?

2:48 amalloy: &(clojure.string/replace "a.b.c-d" #"[.-]" (comp str {\. \/, \- \_} first))

2:48 lazybot: ⇒ "a/b/c_d"

2:49 amalloy: and i guess you could get it shorter if you used strings in the map, instead of going from strings to characters and back

2:49 &(clojure.string/replace "a.b.c-d" #"[.-]" {"." "/", "-" "_"})

2:49 lazybot: ⇒ "a/b/c_d"

2:50 amalloy: dsantiago: ^ all that

2:51 dsantiago: Yeah, I guess in hindsight I can't think of why it isn't that simple.

3:01 tsdh: Hi all.

3:01 ischyrus: Which function takes a list of functions and stops with the first function that returns a non-nil value?

3:01 tsdh: ischyrus: some-fn, I think.

3:01 ischyrus: But that's probably only in clojure 1.3.

3:02 amalloy: tsdh: really, some-fn? that seems silly, whatever it does

3:02 ,(doc some-fn)

3:02 clojurebot: "([p] [p1 p2] [p1 p2 p3] [p1 p2 p3 & ps]); Takes a set of predicates and returns a function f that returns the first logical true value returned by one of its composing predicates against any of its arguments, else it returns logical false. Note that f is short-circuiting in that it will stop execution on the first argument that triggers a logical true result against the original predicates."

3:02 ischyrus: I remember seeing it in 1.2, I just can't recall the name

3:03 amalloy: oh. that

3:03 tsdh: http://clojure.github.com/clojure/branch-master/clojure.core-api.html#clojure.core/some-fn

3:03 amalloy: 's a useful function, but not really related to his request, i think

3:03 ischyrus: i don't think it's a common enough desire that it has a whole top-level name for itself, but it's easy to construct

3:04 &(let [fs [(constantly nil) (constantly true)]] (some #(%) fs))

3:04 lazybot: ⇒ true

3:04 ischyrus: ah, it's cond

3:05 ohwow_: Hellol

3:07 tsdh: I have a function that iterates some seq and picks out elements of a certain type (class). I have a strict (exactly the given class) and a non-strict (subclasses allowed, too) version. The former uses (identical? class (.getClass obj)), the latter (instance? class obj). The interesting thing is that the non-strict version is actually ~3 times faster! How can that be explained?

3:08 amalloy: tsdh: instanceof is a single bytecode instruction, and identical/getClass are methods you have to invoke

3:09 would be my guess

3:09 tsdh: amalloy: Hm, might be. I just wondered because some years ago we were all warned that instanceof and reflection in general is slow...

3:10 amalloy: instanceof has never been slow, and does not use reflection

3:10 tsdh: Ok, then the teacher was wrong. ;-)

3:11 amalloy: it's not as fast as just casting to some known interface and then calling a (polymorphic) method on that interface, but in a java context a lot of instanceof calls are used for bad reasons

3:12 like, instead of defining an interface that classes x, y, z all implement, you test x, then test y, then test z, with special handling for each. *that*'s certainly slower than doing it the right way

3:14 ohwow_: So, if I understand correctly, Clojure doesn't have named LET's?

3:15 If so, how can I do nested loops?

3:15 kumarshantanu: ohwow_: doseq

3:16 (doseq [i (range 100) j [:a :b :c]] (println i j))

3:16 or, doseq within doseq

3:16 ,(doseq [i (range 100) j [:a :b :c]] (println i j))

3:16 clojurebot: 0 :a

3:16 0 :b

3:17 0 :c

3:17 1 :a

3:17 1 :b

3:17 1 :c

3:17 2 :a

3:17 2 :b

3:17 2 :c

3:17 3 :a

3:17 3 :b

3:17 3 :c

3:17 4 :a

3:17 4 :b

3:17 4 :c

3:17 5 :a

3:17 kumarshantanu: clojurebot: stop

3:17 clojurebot: 5 :b

3:17 5 :c

3:17 6 :a

3:17 6 :b

3:17 6 :c

3:17 7 :a

3:17 7 :b

3:17 7 :c

3:17 8 :a

3:17 8 :b

3:17 8 :c

3:17 9 :a

3:17 9 :b

3:17 9 :c

3:17 10 :a

3:17 10 :b

3:17 10 :c

3:17 11 :a

3:17 11 :b

3:17 11 :c

3:17 12 :a

3:17 12 :b

3:17 kumarshantanu: clojurebot: kill

3:17 clojurebot: 12 :c

3:17 13 :a

3:17 13 :b

3:17 13 :c

3:17 14 :a

3:17 14 :b

3:17 14 :c

3:17 15 :a

3:17 15 :b

3:17 15 :c

3:17 16 :a

3:17 16 :b

3:17 16 :c

3:17 17 :a

3:17 17 :b

3:17 17 :c

3:17 18 :a

3:17 18 :b

3:17 18 :c

3:17 19 :a

3:17 19 :b

3:17 19 :c

3:17 20 :a

3:17 kumarshantanu: anybody knows how to stop clourebot from executing a long loop

3:17 clojurebot: 20 :b

3:18 20 :c

3:18 21 :a

3:18 21 :b

3:18 21 :c

3:18 22 :a

3:18 22 :b

3:18 22 :c

3:18 23 :a

3:18 23 :b

3:18 23 :...

3:18 we can't stop here! this is bat country!

3:18 No entiendo

3:18 Pupeno_: It seems it's done.

3:18 ohwow_: oh

3:18 [11:17] < clojurebot> we can't stop here! this is bat country!

3:18 hehe

3:19 well, doseq is not always handy :(

3:19 amalloy: kumarshantanu: i think he has a maximum number of output characters

3:19 and apparently \n is included in that

3:19 ohwow_: (for) follows the same syntax as doseq

3:19 ohwow_: For example, we are trying to find an element in matrix

3:20 and once we found it we must exit

3:20 kumarshantanu: ohwow_: I know what you mean -- this is the toughest part of transitioning to functional programming

3:20 but well worth it

3:20 ohwow_: well,

3:20 I am a Scheme programmer

3:20 so I sould just use nested lets

3:21 and from the inner LET I can call the outer

3:21 kumarshantanu: ohwow_: you can use loop-recur as a last resort

3:21 amalloy: ohwow_: laziness means never having to explicitly exit early

3:23 &(first (let [m [[1 2] [3 4]]] (for [x (range (count m)), y (range (count (first m))), :let [elt (get-in m [x y])], :when (= elt 3)] [x y])))

3:23 lazybot: ⇒ [1 0]

3:23 amalloy: just construct a lazy-seq of all the work, and only consume as much of it as you want

3:24 Pupeno_: There's some kind of shorthand to write functions, like #(+ 1 %), right?

3:24 MasseR: Pupeno_: That's a short anonymous function, yes

3:24 (fn [x] (+ 1 x)) would be the longer version

3:25 Pupeno_: Does that form have a name or where is it documented?

3:25 ohwow_: so Loop returns a lazy sequence?

3:25 amalloy: ohwow_: for does

3:25 ohwow_: oh for

3:25 okay

3:25 I guess I should take my time to get used to lazy programming

3:25 MasseR: Pupeno_: http://clojure.org/other_functions seems to have it

3:26 "#() reader macro"

3:26 amalloy: ohwow_: if you actually use range as in my example, you get tripped up by the fact that range produces a chunked seq, so more elements get realized than you want

3:26 Pupeno_: Thanks.

3:27 amalloy: &(first (let [m [[1 2] [3 4]]] (for [x '(0 1), y '(0 1), :let [elt (get-in m (doto [x y] (->> (println "trying"))))], :when (= elt 3)] [x y])))

3:27 lazybot: ⇒ trying [0 0] trying [0 1] trying [1 0] [1 0]

3:27 MasseR: Altough, I can't find more documentation about it either :/ (then again, I started yesterday)

3:27 Pupeno_: MasseR: yay! Welcome to Clojure... I re-started last week :)

3:27 amalloy: but here i used '(1 0) explicitly for total laziness, and printed each element before testing it; you can see it only went as far as necessary for one match

3:28 ohwow_: hm

3:28 thanks

3:31 Wow, -> macro looks handyu

3:32 amalloy: ohwow_: yeah, that and ->>

3:32 and doto

3:33 and everything else :)

3:55 ohwow_: I have a question regarding clojure-mode for emacs. Why does emacs ident my code like this http://paste.lisp.org/display/123631 ?

3:55 I am using latest clojure-mode from ELPA

3:59 amalloy: ohwow_: that's how it indents lisp-mode too

4:01 i'd guess it sees what the indent is, on the last line on which a sexp at the same level began. here, c began on a line with four spaces

4:02 in fact, if i paredit-reindent-defun, it indents "correctly"

4:03 but the TAB key is bound to something that only looks around locally

4:04 (again, just guessing)

4:10 ohwow_: amalloy: I see, so is there a workaround ?

4:11 amalloy: uh. paredit-reindent-defun?

4:11 bound to M-q by default

4:14 ohwow_: But even if I do it the code looks like http://pastebin.com/LkhseZ43 , not like http://pastebin.com/k0dVZ4tD

4:14 I guess that's because in other Lisps different branches are enclosed in lists

4:18 amalloy: yes

4:27 MasseR: Hmm.. Clojure doesn't have pattern matching by default?

4:31 Pupeno_: MasseR: Rich said so in the Clojure for Java programmers ted talk.

4:32 raek: MasseR: no, it doesn't.

4:45 tufflax: Can I serialize a record using pr-str and read-string somehow? Maybe by going through some additional functions on the way

4:48 MasseR: Couple of koans done. Let's see when I next have the time :P (next would be references)

4:58 amalloy: tufflax: in 1.3, pr-str and read-string with Just Work

4:59 *will

5:08 tufflax: ok

5:09 But if one could turn a map into a record, that should work... is there a way to do that?

5:14 The reason I have not transitioned is mainly because most documentation around is for 1.2 btw. Is there like a new version of the clojure.org docs for 1.3 somewhere? I think it would be a good idea to reread the docs anyway, so it would be 2 birds with 1 stone

5:15 genokuber: is there anyone who sits on #java?

5:15 tufflax: genokuber what do you mean?

5:16 triyo: Anyone have some experience in moustache micro-web-framework?

5:16 JochenR: tufflax:Same with me :-)

5:16 tufflax: :)

5:17 triyo: I have a question about routing and named var bindings and how to pass them on to my view-function

5:19 Here is the codehttps://gist.github.com/1113502

5:20 thorwil: triyo: how does your route look like?

5:20 triyo: https://gist.github.com/1113502

5:20 thorwil: ah, nm

5:21 triyo: Basically what I want is, for my view function to receive "request" binding and and the named params

5:21 something like (defn essay [req slug] (...))

5:21 I'm trying to figure out how it handles this.

5:23 thorwil: oh, that wrap-params can be around several routes is news to me

5:23 triyo: Yup, it can and inline per route-request

5:24 As per docs.... (app ["foo" name] my-handler) ; will route requests to "/foo/", "/foo/bar" to my-handler and bind @name@ (a local) to the matched segment (eg "" or "bar")

5:24 does that mean "name" will become a local thread bound var?

5:25 how does my function receive it including the "request" map?

5:25 thorwil: triyo: a fn inside wrap-params will receive req-params as first and only arg, afaik

5:26 triyo: thorwil: yup, that seems to be the case, because if I try to make my fn with two args, I get IllegalAgEx

5:26 laker: if trying to replace erlang with clojure, is 1 agent per client equivalent to erlang's 1 process/client

5:26 thorwil: to also work with an url segment, you can put in a function that will return an fn that will take the params

5:26 triyo: partial can be useful there

5:27 triyo: True

5:27 Let me try that out quick

5:30 throwil: partial worked

5:31 thorwil: cool

5:31 triyo: however request binding needs to be bound to last argument of function, so instead of (defn essay [req slug] (...)) I swapped the args to (defn essay [slug req] (...))

5:31 this is due to partial.... unless there is something like Haskell's flip function :)

5:32 (comp partial flip) ;-)

5:32 thorwil: well, args in the sequence they will be delivered makes sense, anyway, right? :)

5:33 triyo: yup, true, order doesn't really matter any case that I can think of, well except an `apply` ... but even then req is last

5:35 Though a flip function in clojure would be walk in a park (defn flip [f] (fn [& args] (apply f (reverse args))))

5:45 neotyk: Good morning everyone!

5:49 triyo: morning

5:51 ohwow_: Why `rseq' doesn't work on lists?

5:53 raek: ohwow_: because lists don't have any "natural" way of traversing them backwards

5:54 ohwow_: hm

5:54 Oh, so rseq is lazy, while reverse is not?

5:54 raek: yes

5:54 ohwow_: That makes sense, thanks

5:54 raek: rseq is constant time

5:54 ohwow_: but `rseq' returns a list

5:54 even if I pass a vector to it.

5:55 raek: no, it returns a sequence

5:55 which is a traversal of the elements of a data structure in some order

5:55 ohwow_: ,(rseq '[1 2 3])

5:55 clojurebot: (3 2 1)

5:55 raek: vectors can be traversed in to direction, so you have both seq and rseq

5:55 *two directions

5:56 sequence is an interface (ISeq) and the list (PersistentList) is one implementation

5:56 the vector seq is another

5:57 ,(map class (seq [1 2 3]) (rseq [1 2 3]))

5:57 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: clojure.lang.ArityException: Wrong number of args (2) passed to: core$class>

5:57 ohwow_: Okay, then why does (rseq (seq '[1 2 3])) gives me an error?

5:57 raek: ,(map class [(seq [1 2 3]) (rseq [1 2 3])])

5:57 clojurebot: (clojure.lang.PersistentVector$ChunkedSeq clojure.lang.APersistentVector$RSeq)

5:58 ohwow_: Seq is supposed to return a sequence

5:58 and rseq can take a sequence as an argument

5:58 raek: yes, and sequences does not support rseq in general

5:58 it can?

5:58 ohwow_: hm

5:58 Oh

5:58 morphling: ,(doc rseq)

5:58 clojurebot: "([rev]); Returns, in constant time, a seq of the items in rev (which can be a vector or sorted-map), in reverse order. If rev is empty returns nil"

5:59 raek: rseq work on data structures (vectors, sorted-sets, etc) not sequences

5:59 ohwow_: Oh

5:59 ok, sorry

5:59 I was confused there for a moment

5:59 raek: you can often partition the clojure functions in two camps: those that operate on sequences and those that operate on data structures

6:04 tufflax: raek but clojure is all about programming to abstractions right? So those fns that operates on "data structures" is really just operationg on other abstractions?

6:07 are really*

6:07 raek: yes

6:12 fredeu: Hi! Is this current? (I want to run Emacs/Slime) http://riddell.us/ClojureSwankLeiningenWithEmacsOnLinux.html

6:12 When I follow https://github.com/technomancy/swank-clojure , it tells me to add marmalade to my package-archives -- but the package-archives var apparently doesn't exist... (I'm running emacs pulled yesterday from github.)

6:13 raek: fredeu: no, that one is very old

6:13 the first one

6:14 fredeu: you probably need to install package.el

6:14 technomancy/swank-clojure is the official readme, so that's the one you should follow

6:14 fredeu: are you running emacs 23 or 24? package.el should be included in 24

6:15 fredeu: raek: Thanks! Yeah, I looked at package.el, and it looked to be the same version that's on my distribution (emacs 24)... but I'll recheck...

6:15 I'm running: GNU Emacs (i686-pc-linux-gnu, GTK+ Version 2.24.4) of 2011-07-28 on ubuntu

6:16 raek: then you shouldn't need to install package.el

6:17 fredeu: Hmm... it installed something when I didn't execute the marmalade sexp, but I imagine it's badly outdated...

6:17 (I mean, I skipped the marmalade step.)

6:18 Ah, never mind, I should use the clojure-jack-in method...

6:19 raek: clojure-jack-in is provided by clojure-mode, which you get from marmalade or git

6:19 fredeu: raek: Ok thanks, then git it is. ;)

6:20 raek: can you run M-x package-list-packages ?

6:20 it's strange the var doesn't exist

6:20 fredeu: Yep.

6:21 raek: so you have package.el but you can't add the marmalade repo?

6:21 fredeu: Exactly. But I'm now double-checking everything... maybe there's some weird conflict, or something...

6:23 Yeah, it's so weird, because after a seemingly-successful (require 'package), I keep getting "Debugger entered--Lisp error: (void-variable package-archives)"

6:25 And when I look at vars like package-alist, emacs links me to the "10 Mar 2007" version of package.el -- the same one technomancy links to in the clojure-mode readme.

6:27 Ok, a cleaner .emacs resolves the conflict... Thanks for listening to me yakkk, sorry for taking your time... :)

7:21 wjlroe: Anybody know anything about Maven + Leiningen? I'm having real problems trying to get it to work. When I use the mvn cmd line I can see what errors are happening but they way Leiningen fetches dependencies, it doesn't print useful error messages.

7:22 So I get this error: "[WARNING] repository metadata for: 'artifact org.clojure:clojure' could not be retrieved from repository: artifactory-rel due to an error: Error transferring file" But it doesn't say whether it's an SSL problem or an auth problem...

8:20 MasseR: Haha. "spit" and "slurp"

9:23 (disclaimer: Started learning clojure yesterday) I'm unable to create a executable clojure file. I tried 'lein new foo' and edited the created src clojure file to have (:gen-class) in the namespace. the project.clj has :main and :aot directives. Compiler complains about noclassdeffounderror

9:23 http://asymmetrical-view.com/2010/06/08/building-standalone-jars-wtih-leiningen.html pretty much like this

9:25 lein run complains about the same error

10:06 TimMc: MasseR: I first learned the complement to slurp as "barf", which is a bit more horrifying.

10:06 jcromartie: hah

10:07 ambrosebs: lol

10:11 TimMc: MasseR: When I first started with Clojure, my problems getting lein run to work mostly revolved around misnamed class files or namespaces.

10:12 s/class files and //

10:12 lazybot: What's with you today?

10:13 MasseR: Does your namespace have any hyphens or underscores?

10:13 jcromartie: TimMc: your regex was wrong

10:13 TimMc: yeah?

10:13 MasseR: TimMc: No. http://stackoverflow.com/questions/6874338/standalone-clojure-app

10:13 TimMc: oh, "or"

10:13 Just as well, I don't like that feature.

10:14 MasseR: Are you working from the src folder?

10:14 MasseR: TimMc: Root

10:15 TimMc: I mean, is your "core.clj" in ./src/test/ ?

10:15 MasseR: src/test/core.clj yes

10:15 TimMc: There is also the "test" folder, which is going to be confusing if you also have a namespace called that.

10:15 Hmm, OK.

10:16 You don't need the :aot, by the way, not for this.

10:16 MasseR: Oh ok

10:16 TimMc: What does lein compile do?

10:17 MasseR: The same error

10:17 Hmm.. I moved the same project as is to my desktop computer where it works

10:18 TimMc: huh

10:18 MasseR: My laptop is ubuntu 10.04 with clojure 1.2.1 (not from repositories) and leiningen from git

10:18 The desktop is arch with clojure from repository and leiningen from aur

10:19 TimMc: lein from git?

10:19 Oh, right. github

10:25 Poet_: Hi . Can anyone give me link to simple basic gui tutorial in clojure ? I need something with paint and mouse action listeners . I checked google and i found everything without paint examples

10:26 kumarshantanu: Poet_: Clj-Shoes

10:27 https://github.com/abhijith/clj-shoes

10:33 manutter: Poet_: you might also want to look up SeeSaw (clojure swing tools)

10:37 jcromartie: any comments on my form validation lib? https://gist.github.com/660666aff8742ab77ad9

10:37 I think I need to call it done... I get so distracted by the other stuff

10:38 I spent about 5 hours last night twiddling middleware instead of making progress towards and actual app

10:39 Poet_: kumarshantanu: thank you

10:52 tmountain: is there an official clj script for invoking .clj files or is it still a matter of rolling your own shell script?

10:59 neotyk: Anyone from clojure/core working today on ClojureScript?

11:07 fredeu: Hi! I have lein 1.6.1, which appears not to support the jack-in task. (Or am I missing something?) I installed it today as per the GitHub instructions... should I do something else?

11:07 (I apparently need jack-in for the Slime command clojure-jack-in to work.)

11:16 I'm beginning to think that clojure-mode may be broken, as I don't see the jack-in task in lein's GitHub repo. But it's clearly in clojure-mode: https://github.com/technomancy/clojure-mode/blob/master/clojure-mode.el#L852

11:50 gtrak: anyone know hot to fix "java.lang.ClassNotFoundException: com.sun.jdi.VirtualMachine" with lein ritz ?

11:59 tmountain: found the answer to my question: https://github.com/richhickey/clojure-contrib/blob/master/launchers/bash/clj-env-dir

12:01 technomancy: swank?

12:01 clojurebot: swank is try the readme. seriously.

12:22 hugod: gtrak: I just added the exception explicitly in the ritz readme

12:35 cgrand: Should (rand-nth []) returns nil or (rand-nth nil) throws an exception or the docstring for rand-nth to be "fixed" to say the collection mus not be empty?

14:00 mefesto: Hello everyone. I'm trying to set some jmv options using the JVM_OPTS env var when running a leiningen project. Is there a known issue when using muliple flags or am I doing it wrong? https://gist.github.com/1114355

14:00 s/jmv/jvm/

14:00 lazybot: <mefesto> Hello everyone. I'm trying to set some jvm options using the JVM_OPTS env var when running a leiningen project. Is there a known issue when using muliple flags or am I doing it wrong? https://gist.github.com/1114355

14:01 mefesto: this is the error i receive: "export: 130: -Xms512m: bad variable name"

14:59 manutter: mefesto: try putting "env " in front of your command

15:00 mefesto: manutter: like: env JVM_OPTS="...

15:08 gtrak: hmm, what does slime need to see source from another project?

15:12 I'm trying to hack on source in a lib by running swank on the project that uses the lib, and I've got a symlink to the lib's project root in the using project's checkouts/

15:14 amalloy: gtrak: you don't need to do that. just have the lib as a normal dependency, and M-. one of the symbols it defines when you use it from your code

15:16 gtrak: amalloy, I think the issue is the lib is AOT compiled and doesn't have the source in it

15:16 amalloy: haha ew. you on your own there, sorry

15:18 Pupeno: Is there an easy way to re-start slime after doing clojure-jack-in?

15:19 technomancy: Pupeno: sure: M-x clojure-jack-in

15:20 Pupeno: That didn't work. Should I close swank or some other buffers?

15:20 technomancy: yeah, there's a bug where it doesn't kill the *swank* buffer in some cases; haven't been able to repro here

15:20 you could kill it manually

15:23 Pupeno: Can La Clojure behave like Slime or close?

15:28 hiredman: Pupeno: to what end?

15:29 Pupeno: hiredman: have a REPL and get whole files or parts compiled into it.

15:29 hiredman: ah, does La Clojure not do that by default?

15:29 I just take it as a given that any clojure editor will provide such

15:33 Pupeno: Well… Emacs doesn't do it by default either.

15:33 hiredman: Pupeno: sure, but emacs doesn't have "Clojure" in the name

15:34 which swank-clojure and La Clojure both do

15:34 Pupeno: IntelliJ Idea doesn't either.

15:34 hiredman: (swank-clojure being the bit that provides it for emacs)

15:35 right, emacs+swank-clojure has it, so I would assume La Clojure + IDEA does

15:35 Pupeno: hiredman: you still have to do meta-x clojure-jack-in to get with swank-clojure. It doesn't automagically happens.

15:36 hiredman: Pupeno: I fail to see your point

15:36 Pupeno: hiredman: in Emacs with swank-clojure you have to do something to get the REPL going… I know what it is…. in IntelliJ+La Clojure I don't.

15:36 hiredman: ah

15:36 Pupeno: I think I found how to do it but IntelliJ doesn't know where Clojure is.

15:37 hiredman: you asked "can" instead of "how" up above

15:37 Pupeno: Yeah… I'm still not sure it can do it. It seems it can run a REPL… not sure about compiling little parts and so on.

15:37 hiredman: have you see the getting started with La Clojure page?

15:39 Pupeno: I seen the plugin page (http://plugins.intellij.net/plugin/?id=4050), let me search for that.

15:39 hiredman: http://dev.clojure.org/display/doc/Getting+Started+with+La+Clojure+and+IntelliJ+IDEA

15:39 not that there is much there

15:42 Pupeno: Start Clojure Console is disabled here, apparently, IntelliJ can't find clojure yet :P

15:44 gtrak: how do you guys do find-usages from slime?

15:45 hiredman: there is a slime-who-calls I think

15:45 (as you should be able to tell from the above I don't use it, just rgrep)

15:46 gtrak: rgrep, thanks

15:47 ah, slime-who-calls works great

15:48 except when it doesnt!

15:50 it doesn't seem to catch usages from different files

15:51 netrealm: Ah, okay, this maybe a stupid question, but: How would I go about prepending a colon ":" to an arbitrary string for a map value?

15:52 hiredman: why do you want to do that?

15:52 netrealm: As in, I'm converting an arbitray map to be used by lazy-xml/emit, so trying to go from {somename somevalue} to {:tag :somename :content ["somevalue"]}

15:53 hiredman: http://clojure.org/data_structures#Data%20Structures-Keywords

15:53 netrealm: I have everything working except I can't get :somename

15:53 hiredman: those are not strings

15:53 ,:somename

15:53 clojurebot: :somename

15:53 amalloy: netrealm: i suspect lazy-xml is perfectly happy to have the tag be a symbol/string instead of a keyword

15:54 the new data.xml certainly is

15:55 hiredman: it amazes me that people will pick up a language and try to do something as complex as xml rangling without bothering to learn the language basics

15:55 netrealm: not to pick on you, it happens all the time

15:56 amalloy: too much exposure to ant?

15:57 netrealm: hiredman: yeah...I'm just trying to learn by doing.

15:57 hiredman: clojure.org is required reading

15:57 netrealm: so, I've got (keyword (key v)), where v is an element from my original map, is this the correct way of doing this?

15:58 hiredman: starting from rationale

15:58 it depends on what the key of v is

15:58 netrealm: clojure.org is good, but sometimes I find that I have to start trying to solve problems and find out what I don't understand.

15:59 hiredman: I guess

16:00 netrealm: right, so, I've got (def my-map {somename somevalue othername othervalue}), and I have a function (defn make-xml [v] {:tag (keyword (key v)) :content [(val v)]}), and I do (map make-xml my-map).

16:01 And that gives me my desired output that works with lazy-xml/emit

16:08 imade: amalloy: hey, if you're there, I solved it with lazy-seq like you suggested, thanks for the tip, look at the third solution https://gist.github.com/1112440

16:08 amalloy: imade: ah, cool

16:09 &(take 10 (map first (iterate (fn [[a b]] [b (+ a b)]) [1 1]))) ; is how i usually do it

16:09 lazybot: ⇒ (1 1 2 3 5 8 13 21 34 55)

16:10 amalloy: but the lazy-seq approach is nice, because you don't have to explicitly manage the two-element vector

16:12 dbushenko: how to update clojure version in the counterclockwise?

16:13 imade: amalloy: iterate is a cool function

16:16 dbushenko: cgrand, hi, do you know how to update clojure version in ccw?

16:16 kephale: you know, iterate kind of annoys me actually, not the functionality, but in non-clojure code i use the function name "iterate" all the time

16:16 amalloy: kephale: so use it in clojure too. there's no Shadowing Police

16:17 kephale: amalloy: i know, i just hate potentially confusing people that read my code

16:17 although shadowing police… you could be onto something there

16:19 i might take you up on that if i'm non-lazy enough to keep every such call namespace qualified

16:31 eddayyy: are you supposed to be able to follow ClojureScript quickstart page and not have any problems, or what deps do you need?

16:31 amalloy: in a macro, i want to build a list with 3 elements, say (a b c ); i have a variable elsewhere that tells me whether or not i need to add a fourth element, x, at the end of the list. my usual solution to this is `(a b c ~@(when test [x])), but this is not very readable. does anyone have a better way?

16:37 kephale: can you convert test to a function?

16:37 ##(let [test (fn [x] (when true x))]

16:37 (list 'a 'b 'c (test 'x)))

16:37 &(let [test (fn [x] (when true x))] (list 'a 'b 'c (test 'x)))

16:37 lazybot: ⇒ (a b c x)

16:39 kephale: err in a macro, duh...

16:41 amalloy: kephale: at any rate that would result in a list which is always four elements long, ending with either nil or x

16:42 &`(a b c ~@(when false ['x])) ;; actually only three elements

16:42 lazybot: ⇒ (clojure.core/a clojure.core/b clojure.core/c)

16:42 kephale: indeed… hrm

16:50 eddayyy: CompilerException java.lang.RuntimeException: java.lang.ClassNotFoundException: sun.org.mozilla.javascript.internal.Context, compiling:(cljs/compiler.clj:971)

16:50 anyone have a clue what this means?

16:51 (trying to start clojurescript and get presented with mozilla errors... downloaded rhino & placed jars in classpath (= no-luck))

16:53 amalloy: eddayyy: you're probably trying to use openjdk

16:53 with which cljs is apparently not yet compatible

16:53 eddayyy: amalloy: correct

16:53 amalloy: ah i see, thank you

16:54 Blackfoot: question about clojurescript: when I have code "(.play (goog.fx.dom.FadeOut. counter 1000))" it translates to (new goog.fx.dom.FadeOut(counter__1996,1000)).play

16:54 ie it does not actually run execute play

16:55 kephale: amalloy: what do you have readability issues with there? the @ makes it a little unclear i guess

16:55 amalloy: ##(macroexpand '(.play x)) vs ##(macroexpand '(. x (play)))

16:55 lazybot: (macroexpand (quote (.play x))) ⇒ (. x play)

16:56 (macroexpand (quote (. x (play)))) ⇒ (. x (play))

16:56 amalloy: Blackfoot: on the jvm, the compiler can tell at runtime whether the thing you're trying to get at is a field or a method; in js, functions are just fields, so it needs to know at compile time

16:56 i suspect

16:57 so when you want to call a no-arg "method", i'd play safe with (. x (play))

16:59 Blackfoot: amalloy: thanks, that worked. i haven't used the unsugared notation before

17:00 kephale: amalloy: not in a macro but ##(concat '(a b c) (when true ['x])) ##(concat '(a b c) (when false ['x]))

17:00 lazybot: (concat (quote (a b c)) (when true [(quo... ⇒ (a b c x)

17:00 (concat (quote (a b c)) (when false [(qu... ⇒ (a b c)

17:00 Blackfoot: i wonder if it could eventually tell that it was a function

17:00 kephale: err, i need to learn lazybot...

17:00 amalloy: Blackfoot: so what? even if it is a function, you might be intending to access it as a field and pass it around without calling it

17:01 Pupeno: I got La Clojure working beautifully… documenting how now.

17:01 kephale: i'm not sure if you can get anything smaller than what you have, but concat would hide that nil for you

17:01 amalloy: kephale: the ~@ stuff is basically the same as that concat

17:02 i just feel like there should be an append-if function or something like that. maybe i should just write it

17:04 kephale: amalloy: that does sound like the best way to make it anymore readable without bloat

17:04 any more*

17:05 Blackfoot: amalloy: that doesn't seem to be what http://clojure.org/java_interop indicates is the JVM behavior

17:05 amalloy: If the second operand is a symbol and no args are supplied it is taken to be a field access - the name of the field is the name of the symbol, and the value of the expression is the value of the field, unless there is a no argument public method of the same name, in which case it resolves to a call to the method.

17:06 Blackfoot: amalloy: yea, isn't 'play' a no arguement public method?

17:06 amalloy: no, it is a field, which happens to be a function

17:06 in java, trying to access a method as a field is an error

17:06 so the compiler special-cases that

17:06 in js, it's perfectly fine

17:06 Blackfoot: so javascript doesn't have any methods, basically?

17:07 amalloy: i mean, i'm not a js expert, so that's probably oversimplifying, but yes

17:07 dnolen: Blackfoot: JS just has properties. But if you call a function property, it will have it's context bound to the object to which that function was a property of.

17:08 Blackfoot: but no, "methods" are not an actual construct of the language.

17:08 Blackfoot: hmm, so would ((.play (FadeOut ...)) work? trying...

17:08 amalloy: probably

17:08 Blackfoot: i'm not a js expert either, just playing around with clojurescript. pretty cool stuff

17:09 guess not... Uncaught TypeError: Object [object DOMWindow] has no method 'onBegin'

17:10 generates (new goog.fx.dom.FadeOut(counter__1996,1000)).play.call(null)

17:10 i'm not familiar with the call() function

17:10 dnolen: Blackfoot: "this" was not set.

17:10 Blackfoot: all functions have a call property which allows to do 2 things

17:10 1) set the value of 'this' 2) pass the args

17:11 .call(object, a0, a1, ..., an)

17:11 in your case object was probably set to null

17:12 Blackfoot: yea looks like it

17:14 dnolen: Blackfoot: in anycase (. x (play)) is what you want because of in JS you just have properties.

17:14 Blackfoot: yep, that is working. I like learning about the reasons why, too, thanks for the explanations

17:36 kyleburton: hello

17:37 anyone running into RejectedExecutionException's with lein? I upgraded to 1.6.1 and build swank-clojure from Technomancy's git repo just to make sure I was up to date...

17:37 trying to load a file, I get that exception

17:39 hiredman: your swank-clojure isn't really up to date, double check

17:41 duncanm: how that i program in JRuby, i really appreciate the Clojure reader decision to require explicit forward declarations

17:41 kyleburton: thank you - Technomancy responded on #leiningen

17:42 I couldn't see it, but he said I had an 1.3.2 on my classpath - nuking my ~/.m2/repo/.../swank-clojure dirs fixed it

17:42 thanks!

17:57 Raynes: I wonder if Stuart Sierra knew that he didn't have to fork clojurescript to clojure. You can actually move repositories, watchers and all, from the admin panel.

17:57 Not that it matters. The repository was private, so there weren't any watchers to propagate.

19:01 momox: what does this line of code do? http://pastebin.com/sdCAhDPq

19:01 its part of the source code of conj

19:01 amalloy: it calls clojure.lang.RT.conj

19:01 which is in java

19:02 hiredman: clojure.lang.RT/conj

19:06 momox: amalloy: i can't view the source from the repl?

19:07 hiredman: it's a java method

19:09 momox: hiredman: so the only way to view it is to open the .java file using a text editor?

19:09 hiredman: *shrug* whatever floats your boat

19:10 amalloy: other ways include: looking at the .java file on github

19:13 momox: good idea

19:13 thanks hiredman and amalloy

19:19 it looks like that line of code will keep on calling itself over and over again

19:19 (conj coll x)

19:20 hiredman: http://clojure.org/java_interop

19:25 the-kenny: Thanks for implementing Multimethods in ClojureScript. Makes my life so much easier :)

19:25 dnolen: momox: the Clojure code is calling out to Java to do the actual work.

19:26 the-kenny: did multimethods get merged to master?

19:26 the-kenny: dnolen: Yup

19:29 momox: dnolen: thanks. I understand it now. Just realised that (. Classname-symbol (method-symbol args*)) is equivalent to (. Classname-symbol method-symbol args*)

20:15 pmbauer: [ANN] First Clojure User Group Meeting. https://groups.google.com/d/msg/clj-phx/l_S4qcOSuaY/WhOC7T8HOK8J

20:15 Phoenix, AZ

20:15 http://clj-phx.wikispaces.com/

20:15 That is all, thank you!

20:27 dnolen: pmbauer: cool!

20:31 Pupeno: Here's how I got La Clojure working: http://pupeno.com/blog/getting-started-with-la-clojure-on-mac-os-x-a-visual-guide/

20:33 hiredman: well there is your problem right there

20:33 using the system package manager to install clojure

20:35 you should be fetching it from a maven repo via lein/maven

20:54 tauntaun: Newbie Q: Any reason why I can't (import '(javax.swing SwingUtilities)) in Clojure, seeing as I can import it in Java?

20:55 hiredman: what makes you think you cannot import it?

20:55 tauntaun: Nevermind :) It was a typo...

21:18 dnolen: man i love metadata on symbols.

21:25 if anybody wants to follow along the pattern matching / predicate dispatch developments, you can check in here, https://github.com/swannodette/match/wiki/Design-Wiki, not much there yet, but there will be.

21:27 hiredman: dnolen: "3 or 4" means it depends on the ordering?

21:27 dnolen: hiredman: yeah. those are ambrose notes.

22:58 sritchie: hey all -- this is a very beginner web development question, but I was wondering -- would it make sense to embed clojurescript in an existing rails application, for some view that requires lots of UI?

22:58 I'm trying to get a feel for how these web stacks incorporate their js

23:08 gfrlog: sritchie: that sounds like a pretty tame use case to me

23:09 sritchie: haha, sure, I get that

23:11 gfrlog: um. so yes it makes sense?

23:11 sritchie: I just don't have a good feel for, say, whether to design a full application in clojurescript, scrapping the rails part, or whether it finds its place nested in another web framework

23:12 Scriptor: sritchie: that's more of a choice in what you want your app to be like

23:12 if you go for clojurescript-only, that means you already decided you want to have a one-page app, basically a desktop app in a browser

23:12 and have something like sinatra on the server

23:12 sritchie: I see

23:13 so a more complicated data model would push toward a need for a bigger web framework to back clojurescript

23:13 Scriptor: not really

23:14 what do you mean by a more complicated data model? Google Docs is a good example of a one-page app and it seems pretty complicated :)

23:14 sritchie: I'll lay out what I'm thinking -- I'm designing a registration system for kayak regattas

23:14 these are sprint races, with a progression based on a set of rules -- so, users need to be able to register for races all season, and the particular regatta events contain logic to manage progressions, juggle results, etc

23:16 beyond that, athletes are members of teams, which have their own area within the site

23:16 I'm not saying at all that I don't think clojurescript can handle that stuff -- I'm just not familiar with the javascript side of all this, so I'm trying to get a feel for how one might make the decision between going full-clojurescript vs rails et al

23:17 Scriptor: hmm, it's not really a matter of clojurescript vs rails

23:17 keep in mind that the niche clojurescript is meant to be an alternative to something like dojo, extjs, or yui

23:17 basically, heavyweight js frameworks

23:18 it's perfectly fine to have clojurescript and rails at the same time

23:18 just like you can have dojo and rails at the same time

23:19 sritchie: great, this gives me a good place to start absorbing

23:21 goodieboy: what is "&" in clojure? for example when using defn to specify optional arguments...

23:22 sritchie: goodieboy: & packs all optional arguments (if they exist) into a list bound to the var following &

23:22 Scriptor: in the simplest sense, it means all remaining arguments that are passed are bound as a list to the variable name that comes after the &

23:22 amalloy: argh don't encourage him to think of it as "optional"

23:23 "additional", or "further" or something. "optional" implies, among other things, that you could put multiple bindings after the &

23:23 sritchie: amalloy: good point, sorry about that

23:23 amalloy: just the other day someone was asking why (fn [x & y z]) didn't work

23:24 anyway, Scriptor's definition is good

23:25 leonid_: is there a way to define a var arg function using #()?

23:25 amalloy: %&

23:25 leonid_: !

23:26 thanks !

23:26 amalloy: clojure and perl: members of a small group of languages in which you can answer a question using only punctuation

23:26 goodieboy: ok thanks guys, i guess i'm wondering more about if it's just defn that sees & as something "special" or if the language itself sees & as a global "keyword" of sorts?

23:27 amalloy: goodieboy: mostly, it's just defn (actually, it's destructure, which is used by fn and by let)

23:28 i learned recently that that's a bit of a simplification, but i didn't encounter any of the exceptions for over a year

23:29 goodieboy: cool ok thanks... coming from ruby, this homoiconic stuff is fascinating :)

23:29 amalloy: (and when i did, i was doing something evil. so you shouldn't worry about it)

23:30 specifically, it turns out you can't define a macro named &

23:30 because the reader refuses to macroexpand it

23:30 goodieboy: oh really? so it is something "special"?

23:30 ahh ok

23:30 amalloy: like i said, there are some exceptions

23:30 but you won't see them unless you're evil

23:31 goodieboy: ok good to know. well, i am not evil, but wish i were :)

23:32 amalloy: well, lisp is a good place to start: http://tch515866.tch.quora.com/My-5-year-old-daughter-is-interested-in-becoming-Empress-of-the-Universe-as-a-career-path-What-programming-languages-technologies-should-I-teach-her-to-aid-her-galaxy-domination-goals

23:32 jeez that's a stupidly long url

23:33 goodieboy: wow that is long but thanks! i go back to the sicp ebook all the time, just trying to grasp as much as possible. awesome stuff.

23:36 ha ha, the last comment is the best

23:56 rimmjob_: is there a list of differences between clojure and emacs lisp ?

23:56 lucca: indirectly

23:56 amalloy: differences (1) they are very different

23:56 (2) see 1?

23:57 lucca: http://clojure.org/lisps might help

23:57 depending on how well you know elisp

23:57 rimmjob_: thankee

23:58 amalloy: lucca: someone should fix "All (global) Vars can be dynamically rebound without interfering with lexical local bindings. No special declarations are necessary to distinguish between dynamic and lexical bindings. Since Clojure is a Lisp-1, (global) functions can be dynamically rebound."

23:58 hiredman: the docs are from the last release (1.2.x)

23:59 amalloy: or...maybe not? it reads like they're saying you can rebind things without special declarations, but when i look closer i can't see it actually saying that

Logging service provided by n01se.net