#clojure logs

2011-07-29

00:15jcromartierock on
00:16PupenoGood morning.
00:24jcromartiethat reminds me... it's time to go to bed
00:44PupenoWhat's the best way to run Clojure tests in Emacs? I'm using Slime.
00:56scottjPupeno: 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
00:56jcromartieyeah
00:56jcromartiethat's the way to go
00:57jcromartieso I said to myself "hey it would be cool to have a really dead simple CMS/string-management/localization as part of this app"
00:57jcromartiemiddleware!
00:57jcromartie(wrap-localization)
00:58jcromartiewhich replaces $foo$ in the body of the response with the localized string for key "foo"
01:31jcromartieexcept, $ doesn't work with the nice replace in str-utils2 !
01:31jcromartieit complains of an invalid group
01:32jcromartienah nevermind
02:25lakerhello, what's clojure's answer to heavy client concurrency, is 1 agent per client a reasonable option?
02:47dsantiagoIs 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"?
02:48amalloy&(clojure.string/replace "a.b.c-d" #"[.-]" (comp str {\. \/, \- \_} first))
02:48lazybot⇒ "a/b/c_d"
02:49amalloyand i guess you could get it shorter if you used strings in the map, instead of going from strings to characters and back
02:49amalloy&(clojure.string/replace "a.b.c-d" #"[.-]" {"." "/", "-" "_"})
02:49lazybot⇒ "a/b/c_d"
02:50amalloydsantiago: ^ all that
02:51dsantiagoYeah, I guess in hindsight I can't think of why it isn't that simple.
03:01tsdhHi all.
03:01ischyrusWhich function takes a list of functions and stops with the first function that returns a non-nil value?
03:01tsdhischyrus: some-fn, I think.
03:01tsdhischyrus: But that's probably only in clojure 1.3.
03:02amalloytsdh: really, some-fn? that seems silly, whatever it does
03:02amalloy,(doc some-fn)
03:02clojurebot"([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."
03:02ischyrusI remember seeing it in 1.2, I just can't recall the name
03:03amalloyoh. that
03:03tsdhhttp://clojure.github.com/clojure/branch-master/clojure.core-api.html#clojure.core/some-fn
03:03amalloy's a useful function, but not really related to his request, i think
03:03amalloyischyrus: 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
03:04amalloy&(let [fs [(constantly nil) (constantly true)]] (some #(%) fs))
03:04lazybot⇒ true
03:04ischyrusah, it's cond
03:05ohwow_Hellol
03:07tsdhI 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?
03:08amalloytsdh: instanceof is a single bytecode instruction, and identical/getClass are methods you have to invoke
03:09amalloywould be my guess
03:09tsdhamalloy: Hm, might be. I just wondered because some years ago we were all warned that instanceof and reflection in general is slow...
03:10amalloyinstanceof has never been slow, and does not use reflection
03:10tsdhOk, then the teacher was wrong. ;-)
03:11amalloyit'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
03:12amalloylike, 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
03:14ohwow_So, if I understand correctly, Clojure doesn't have named LET's?
03:15ohwow_If so, how can I do nested loops?
03:15kumarshantanuohwow_: doseq
03:16kumarshantanu(doseq [i (range 100) j [:a :b :c]] (println i j))
03:16kumarshantanuor, doseq within doseq
03:16kumarshantanu,(doseq [i (range 100) j [:a :b :c]] (println i j))
03:16clojurebot0 :a
03:16clojurebot0 :b
03:17clojurebot0 :c
03:17clojurebot1 :a
03:17clojurebot1 :b
03:17clojurebot1 :c
03:17clojurebot2 :a
03:17clojurebot2 :b
03:17clojurebot2 :c
03:17clojurebot3 :a
03:17clojurebot3 :b
03:17clojurebot3 :c
03:17clojurebot4 :a
03:17clojurebot4 :b
03:17clojurebot4 :c
03:17clojurebot5 :a
03:17kumarshantanuclojurebot: stop
03:17clojurebot5 :b
03:17clojurebot5 :c
03:17clojurebot6 :a
03:17clojurebot6 :b
03:17clojurebot6 :c
03:17clojurebot7 :a
03:17clojurebot7 :b
03:17clojurebot7 :c
03:17clojurebot8 :a
03:17clojurebot8 :b
03:17clojurebot8 :c
03:17clojurebot9 :a
03:17clojurebot9 :b
03:17clojurebot9 :c
03:17clojurebot10 :a
03:17clojurebot10 :b
03:17clojurebot10 :c
03:17clojurebot11 :a
03:17clojurebot11 :b
03:17clojurebot11 :c
03:17clojurebot12 :a
03:17clojurebot12 :b
03:17kumarshantanuclojurebot: kill
03:17clojurebot12 :c
03:17clojurebot13 :a
03:17clojurebot13 :b
03:17clojurebot13 :c
03:17clojurebot14 :a
03:17clojurebot14 :b
03:17clojurebot14 :c
03:17clojurebot15 :a
03:17clojurebot15 :b
03:17clojurebot15 :c
03:17clojurebot16 :a
03:17clojurebot16 :b
03:17clojurebot16 :c
03:17clojurebot17 :a
03:17clojurebot17 :b
03:17clojurebot17 :c
03:17clojurebot18 :a
03:17clojurebot18 :b
03:17clojurebot18 :c
03:17clojurebot19 :a
03:17clojurebot19 :b
03:17clojurebot19 :c
03:17clojurebot20 :a
03:17kumarshantanuanybody knows how to stop clourebot from executing a long loop
03:17clojurebot20 :b
03:18clojurebot20 :c
03:18clojurebot21 :a
03:18clojurebot21 :b
03:18clojurebot21 :c
03:18clojurebot22 :a
03:18clojurebot22 :b
03:18clojurebot22 :c
03:18clojurebot23 :a
03:18clojurebot23 :b
03:18clojurebot23 :...
03:18clojurebotwe can't stop here! this is bat country!
03:18clojurebotNo entiendo
03:18Pupeno_It seems it's done.
03:18ohwow_oh
03:18ohwow_[11:17] < clojurebot> we can't stop here! this is bat country!
03:18ohwow_hehe
03:19ohwow_well, doseq is not always handy :(
03:19amalloykumarshantanu: i think he has a maximum number of output characters
03:19amalloyand apparently \n is included in that
03:19amalloyohwow_: (for) follows the same syntax as doseq
03:19ohwow_For example, we are trying to find an element in matrix
03:20ohwow_and once we found it we must exit
03:20kumarshantanuohwow_: I know what you mean -- this is the toughest part of transitioning to functional programming
03:20kumarshantanubut well worth it
03:20ohwow_well,
03:20ohwow_I am a Scheme programmer
03:20ohwow_so I sould just use nested lets
03:21ohwow_and from the inner LET I can call the outer
03:21kumarshantanuohwow_: you can use loop-recur as a last resort
03:21amalloyohwow_: laziness means never having to explicitly exit early
03:23amalloy&(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])))
03:23lazybot⇒ [1 0]
03:23amalloyjust construct a lazy-seq of all the work, and only consume as much of it as you want
03:24Pupeno_There's some kind of shorthand to write functions, like #(+ 1 %), right?
03:24MasseRPupeno_: That's a short anonymous function, yes
03:24MasseR(fn [x] (+ 1 x)) would be the longer version
03:25Pupeno_Does that form have a name or where is it documented?
03:25ohwow_so Loop returns a lazy sequence?
03:25amalloyohwow_: for does
03:25ohwow_oh for
03:25ohwow_okay
03:25ohwow_I guess I should take my time to get used to lazy programming
03:25MasseRPupeno_: http://clojure.org/other_functions seems to have it
03:26MasseR"#() reader macro"
03:26amalloyohwow_: 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
03:26Pupeno_Thanks.
03:27amalloy&(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])))
03:27lazybot⇒ trying [0 0] trying [0 1] trying [1 0] [1 0]
03:27MasseRAltough, I can't find more documentation about it either :/ (then again, I started yesterday)
03:27Pupeno_MasseR: yay! Welcome to Clojure... I re-started last week :)
03:27amalloybut 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
03:28ohwow_hm
03:28ohwow_thanks
03:31ohwow_Wow, -> macro looks handyu
03:32amalloyohwow_: yeah, that and ->>
03:32amalloyand doto
03:33amalloyand everything else :)
03:55ohwow_I have a question regarding clojure-mode for emacs. Why does emacs ident my code like this http://paste.lisp.org/display/123631 ?
03:55ohwow_I am using latest clojure-mode from ELPA
03:59amalloyohwow_: that's how it indents lisp-mode too
04:01amalloyi'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
04:02amalloyin fact, if i paredit-reindent-defun, it indents "correctly"
04:03amalloybut the TAB key is bound to something that only looks around locally
04:04amalloy(again, just guessing)
04:10ohwow_amalloy: I see, so is there a workaround ?
04:11amalloyuh. paredit-reindent-defun?
04:11amalloybound to M-q by default
04:14ohwow_But even if I do it the code looks like http://pastebin.com/LkhseZ43 , not like http://pastebin.com/k0dVZ4tD
04:14ohwow_I guess that's because in other Lisps different branches are enclosed in lists
04:18amalloyyes
04:27MasseRHmm.. Clojure doesn't have pattern matching by default?
04:31Pupeno_MasseR: Rich said so in the Clojure for Java programmers ted talk.
04:32raekMasseR: no, it doesn't.
04:45tufflaxCan I serialize a record using pr-str and read-string somehow? Maybe by going through some additional functions on the way
04:48MasseRCouple of koans done. Let's see when I next have the time :P (next would be references)
04:58amalloytufflax: in 1.3, pr-str and read-string with Just Work
04:59amalloy*will
05:08tufflaxok
05:09tufflaxBut if one could turn a map into a record, that should work... is there a way to do that?
05:14tufflaxThe 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
05:15genokuberis there anyone who sits on #java?
05:15tufflaxgenokuber what do you mean?
05:16triyoAnyone have some experience in moustache micro-web-framework?
05:16JochenRtufflax:Same with me :-)
05:16tufflax:)
05:17triyoI have a question about routing and named var bindings and how to pass them on to my view-function
05:19triyoHere is the codehttps://gist.github.com/1113502
05:20thorwiltriyo: how does your route look like?
05:20triyohttps://gist.github.com/1113502
05:20thorwilah, nm
05:21triyoBasically what I want is, for my view function to receive "request" binding and and the named params
05:21triyosomething like (defn essay [req slug] (...))
05:21triyoI'm trying to figure out how it handles this.
05:23thorwiloh, that wrap-params can be around several routes is news to me
05:23triyoYup, it can and inline per route-request
05:24triyoAs 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")
05:24triyodoes that mean "name" will become a local thread bound var?
05:25triyohow does my function receive it including the "request" map?
05:25thorwiltriyo: a fn inside wrap-params will receive req-params as first and only arg, afaik
05:26triyothorwil: yup, that seems to be the case, because if I try to make my fn with two args, I get IllegalAgEx
05:26lakerif trying to replace erlang with clojure, is 1 agent per client equivalent to erlang's 1 process/client
05:26thorwilto also work with an url segment, you can put in a function that will return an fn that will take the params
05:26thorwiltriyo: partial can be useful there
05:27triyoTrue
05:27triyoLet me try that out quick
05:30triyothrowil: partial worked
05:31thorwilcool
05:31triyohowever 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] (...))
05:31triyothis is due to partial.... unless there is something like Haskell's flip function :)
05:32triyo(comp partial flip) ;-)
05:32thorwilwell, args in the sequence they will be delivered makes sense, anyway, right? :)
05:33triyoyup, true, order doesn't really matter any case that I can think of, well except an `apply` ... but even then req is last
05:35triyoThough a flip function in clojure would be walk in a park (defn flip [f] (fn [& args] (apply f (reverse args))))
05:45neotykGood morning everyone!
05:49triyomorning
05:51ohwow_Why `rseq' doesn't work on lists?
05:53raekohwow_: because lists don't have any "natural" way of traversing them backwards
05:54ohwow_hm
05:54ohwow_Oh, so rseq is lazy, while reverse is not?
05:54raekyes
05:54ohwow_That makes sense, thanks
05:54raekrseq is constant time
05:54ohwow_but `rseq' returns a list
05:54ohwow_even if I pass a vector to it.
05:55raekno, it returns a sequence
05:55raekwhich is a traversal of the elements of a data structure in some order
05:55ohwow_,(rseq '[1 2 3])
05:55clojurebot(3 2 1)
05:55raekvectors can be traversed in to direction, so you have both seq and rseq
05:55raek*two directions
05:56raeksequence is an interface (ISeq) and the list (PersistentList) is one implementation
05:56raekthe vector seq is another
05:57raek,(map class (seq [1 2 3]) (rseq [1 2 3]))
05:57clojurebot#<ExecutionException java.util.concurrent.ExecutionException: clojure.lang.ArityException: Wrong number of args (2) passed to: core$class>
05:57ohwow_Okay, then why does (rseq (seq '[1 2 3])) gives me an error?
05:57raek,(map class [(seq [1 2 3]) (rseq [1 2 3])])
05:57clojurebot(clojure.lang.PersistentVector$ChunkedSeq clojure.lang.APersistentVector$RSeq)
05:58ohwow_Seq is supposed to return a sequence
05:58ohwow_and rseq can take a sequence as an argument
05:58raekyes, and sequences does not support rseq in general
05:58raekit can?
05:58ohwow_hm
05:58ohwow_Oh
05:58morphling,(doc rseq)
05:58clojurebot"([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"
05:59raekrseq work on data structures (vectors, sorted-sets, etc) not sequences
05:59ohwow_Oh
05:59ohwow_ok, sorry
05:59ohwow_I was confused there for a moment
05:59raekyou can often partition the clojure functions in two camps: those that operate on sequences and those that operate on data structures
06:04tufflaxraek but clojure is all about programming to abstractions right? So those fns that operates on "data structures" is really just operationg on other abstractions?
06:07tufflaxare really*
06:07raekyes
06:12fredeuHi! Is this current? (I want to run Emacs/Slime) http://riddell.us/ClojureSwankLeiningenWithEmacsOnLinux.html
06:12fredeuWhen 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.)
06:13raekfredeu: no, that one is very old
06:13raekthe first one
06:14raekfredeu: you probably need to install package.el
06:14raektechnomancy/swank-clojure is the official readme, so that's the one you should follow
06:14raekfredeu: are you running emacs 23 or 24? package.el should be included in 24
06:15fredeuraek: 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...
06:15fredeuI'm running: GNU Emacs 24.0.50.1 (i686-pc-linux-gnu, GTK+ Version 2.24.4) of 2011-07-28 on ubuntu
06:16raekthen you shouldn't need to install package.el
06:17fredeuHmm... it installed something when I didn't execute the marmalade sexp, but I imagine it's badly outdated...
06:17fredeu(I mean, I skipped the marmalade step.)
06:18fredeuAh, never mind, I should use the clojure-jack-in method...
06:19raekclojure-jack-in is provided by clojure-mode, which you get from marmalade or git
06:19fredeuraek: Ok thanks, then git it is. ;)
06:20raekcan you run M-x package-list-packages ?
06:20raekit's strange the var doesn't exist
06:20fredeuYep.
06:21raekso you have package.el but you can't add the marmalade repo?
06:21fredeuExactly. But I'm now double-checking everything... maybe there's some weird conflict, or something...
06:23fredeuYeah, it's so weird, because after a seemingly-successful (require 'package), I keep getting "Debugger entered--Lisp error: (void-variable package-archives)"
06:25fredeuAnd 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.
06:27fredeuOk, a cleaner .emacs resolves the conflict... Thanks for listening to me yakkk, sorry for taking your time... :)
07:21wjlroeAnybody 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.
07:22wjlroeSo 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...
08:20MasseRHaha. "spit" and "slurp"
09:23MasseR(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
09:23MasseRhttp://asymmetrical-view.com/2010/06/08/building-standalone-jars-wtih-leiningen.html pretty much like this
09:25MasseRlein run complains about the same error
10:06TimMcMasseR: I first learned the complement to slurp as "barf", which is a bit more horrifying.
10:06jcromartiehah
10:07ambrosebslol
10:11TimMcMasseR: When I first started with Clojure, my problems getting lein run to work mostly revolved around misnamed class files or namespaces.
10:12TimMcs/class files and //
10:12TimMclazybot: What's with you today?
10:13TimMcMasseR: Does your namespace have any hyphens or underscores?
10:13jcromartieTimMc: your regex was wrong
10:13TimMcyeah?
10:13MasseRTimMc: No. http://stackoverflow.com/questions/6874338/standalone-clojure-app
10:13TimMcoh, "or"
10:13TimMcJust as well, I don't like that feature.
10:14TimMcMasseR: Are you working from the src folder?
10:14MasseRTimMc: Root
10:15TimMcI mean, is your "core.clj" in ./src/test/ ?
10:15MasseRsrc/test/core.clj yes
10:15TimMcThere is also the "test" folder, which is going to be confusing if you also have a namespace called that.
10:15TimMcHmm, OK.
10:16TimMcYou don't need the :aot, by the way, not for this.
10:16MasseROh ok
10:16TimMcWhat does lein compile do?
10:17MasseRThe same error
10:17MasseRHmm.. I moved the same project as is to my desktop computer where it works
10:18TimMchuh
10:18MasseRMy laptop is ubuntu 10.04 with clojure 1.2.1 (not from repositories) and leiningen from git
10:18MasseRThe desktop is arch with clojure from repository and leiningen from aur
10:19TimMclein from git?
10:19TimMcOh, right. github
10:25Poet_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:26kumarshantanuPoet_: Clj-Shoes
10:27kumarshantanuhttps://github.com/abhijith/clj-shoes
10:33manutterPoet_: you might also want to look up SeeSaw (clojure swing tools)
10:37jcromartieany comments on my form validation lib? https://gist.github.com/660666aff8742ab77ad9
10:37jcromartieI think I need to call it done... I get so distracted by the other stuff
10:38jcromartieI spent about 5 hours last night twiddling middleware instead of making progress towards and actual app
10:39Poet_kumarshantanu: thank you
10:52tmountainis there an official clj script for invoking .clj files or is it still a matter of rolling your own shell script?
10:59neotykAnyone from clojure/core working today on ClojureScript?
11:07fredeuHi! 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:07fredeu(I apparently need jack-in for the Slime command clojure-jack-in to work.)
11:16fredeuI'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:50gtrakanyone know hot to fix "java.lang.ClassNotFoundException: com.sun.jdi.VirtualMachine" with lein ritz ?
11:59tmountainfound the answer to my question: https://github.com/richhickey/clojure-contrib/blob/master/launchers/bash/clj-env-dir
12:01technomancyswank?
12:01clojurebotswank is try the readme. seriously.
12:22hugodgtrak: I just added the exception explicitly in the ritz readme
12:35cgrandShould (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:00mefestoHello 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:00mefestos/jmv/jvm/
14:00lazybot<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:01mefestothis is the error i receive: "export: 130: -Xms512m: bad variable name"
14:59manuttermefesto: try putting "env " in front of your command
15:00mefestomanutter: like: env JVM_OPTS="...
15:08gtrakhmm, what does slime need to see source from another project?
15:12gtrakI'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:14amalloygtrak: 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:16gtrakamalloy, I think the issue is the lib is AOT compiled and doesn't have the source in it
15:16amalloyhaha ew. you on your own there, sorry
15:18PupenoIs there an easy way to re-start slime after doing clojure-jack-in?
15:19technomancyPupeno: sure: M-x clojure-jack-in
15:20PupenoThat didn't work. Should I close swank or some other buffers?
15:20technomancyyeah, there's a bug where it doesn't kill the *swank* buffer in some cases; haven't been able to repro here
15:20technomancyyou could kill it manually
15:23PupenoCan La Clojure behave like Slime or close?
15:28hiredmanPupeno: to what end?
15:29Pupenohiredman: have a REPL and get whole files or parts compiled into it.
15:29hiredmanah, does La Clojure not do that by default?
15:29hiredmanI just take it as a given that any clojure editor will provide such
15:33PupenoWell… Emacs doesn't do it by default either.
15:33hiredmanPupeno: sure, but emacs doesn't have "Clojure" in the name
15:34hiredmanwhich swank-clojure and La Clojure both do
15:34PupenoIntelliJ Idea doesn't either.
15:34hiredman(swank-clojure being the bit that provides it for emacs)
15:35hiredmanright, emacs+swank-clojure has it, so I would assume La Clojure + IDEA does
15:35Pupenohiredman: you still have to do meta-x clojure-jack-in to get with swank-clojure. It doesn't automagically happens.
15:36hiredmanPupeno: I fail to see your point
15:36Pupenohiredman: 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:36hiredmanah
15:36PupenoI think I found how to do it but IntelliJ doesn't know where Clojure is.
15:37hiredmanyou asked "can" instead of "how" up above
15:37PupenoYeah… 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:37hiredmanhave you see the getting started with La Clojure page?
15:39PupenoI seen the plugin page (http://plugins.intellij.net/plugin/?id=4050), let me search for that.
15:39hiredmanhttp://dev.clojure.org/display/doc/Getting+Started+with+La+Clojure+and+IntelliJ+IDEA
15:39hiredmannot that there is much there
15:42PupenoStart Clojure Console is disabled here, apparently, IntelliJ can't find clojure yet :P
15:44gtrakhow do you guys do find-usages from slime?
15:45hiredmanthere is a slime-who-calls I think
15:45hiredman(as you should be able to tell from the above I don't use it, just rgrep)
15:46gtrakrgrep, thanks
15:47gtrakah, slime-who-calls works great
15:48gtrakexcept when it doesnt!
15:50gtrakit doesn't seem to catch usages from different files
15:51netrealmAh, okay, this maybe a stupid question, but: How would I go about prepending a colon ":" to an arbitrary string for a map value?
15:52hiredmanwhy do you want to do that?
15:52netrealmAs 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:53hiredmanhttp://clojure.org/data_structures#Data%20Structures-Keywords
15:53netrealmI have everything working except I can't get :somename
15:53hiredmanthose are not strings
15:53hiredman,:somename
15:53clojurebot:somename
15:53amalloynetrealm: i suspect lazy-xml is perfectly happy to have the tag be a symbol/string instead of a keyword
15:54amalloythe new data.xml certainly is
15:55hiredmanit 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:55hiredmannetrealm: not to pick on you, it happens all the time
15:56amalloytoo much exposure to ant?
15:57netrealmhiredman: yeah...I'm just trying to learn by doing.
15:57hiredmanclojure.org is required reading
15:57netrealmso, I've got (keyword (key v)), where v is an element from my original map, is this the correct way of doing this?
15:58hiredmanstarting from rationale
15:58hiredmanit depends on what the key of v is
15:58netrealmclojure.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:59hiredmanI guess
16:00netrealmright, 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:01netrealmAnd that gives me my desired output that works with lazy-xml/emit
16:08imadeamalloy: 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:08amalloyimade: ah, cool
16:09amalloy&(take 10 (map first (iterate (fn [[a b]] [b (+ a b)]) [1 1]))) ; is how i usually do it
16:09lazybot⇒ (1 1 2 3 5 8 13 21 34 55)
16:10amalloybut the lazy-seq approach is nice, because you don't have to explicitly manage the two-element vector
16:12dbushenkohow to update clojure version in the counterclockwise?
16:13imadeamalloy: iterate is a cool function
16:16dbushenkocgrand, hi, do you know how to update clojure version in ccw?
16:16kephaleyou 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:16amalloykephale: so use it in clojure too. there's no Shadowing Police
16:17kephaleamalloy: i know, i just hate potentially confusing people that read my code
16:17kephalealthough shadowing police… you could be onto something there
16:19kephalei might take you up on that if i'm non-lazy enough to keep every such call namespace qualified
16:31eddayyyare you supposed to be able to follow ClojureScript quickstart page and not have any problems, or what deps do you need?
16:31amalloyin 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:37kephalecan you convert test to a function?
16:37kephale##(let [test (fn [x] (when true x))]
16:37kephale (list 'a 'b 'c (test 'x)))
16:37kephale&(let [test (fn [x] (when true x))] (list 'a 'b 'c (test 'x)))
16:37lazybot⇒ (a b c x)
16:39kephaleerr in a macro, duh...
16:41amalloykephale: at any rate that would result in a list which is always four elements long, ending with either nil or x
16:42amalloy&`(a b c ~@(when false ['x])) ;; actually only three elements
16:42lazybot⇒ (clojure.core/a clojure.core/b clojure.core/c)
16:42kephaleindeed… hrm
16:50eddayyyCompilerException java.lang.RuntimeException: java.lang.ClassNotFoundException: sun.org.mozilla.javascript.internal.Context, compiling:(cljs/compiler.clj:971)
16:50eddayyyanyone have a clue what this means?
16:51eddayyy(trying to start clojurescript and get presented with mozilla errors... downloaded rhino & placed jars in classpath (= no-luck))
16:53amalloyeddayyy: you're probably trying to use openjdk
16:53amalloywith which cljs is apparently not yet compatible
16:53eddayyyamalloy: correct
16:53eddayyyamalloy: ah i see, thank you
16:54Blackfootquestion 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:54Blackfootie it does not actually run execute play
16:55kephaleamalloy: what do you have readability issues with there? the @ makes it a little unclear i guess
16:55amalloy##(macroexpand '(.play x)) vs ##(macroexpand '(. x (play)))
16:55lazybot (macroexpand (quote (.play x))) ⇒ (. x play)
16:56lazybot (macroexpand (quote (. x (play)))) ⇒ (. x (play))
16:56amalloyBlackfoot: 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:56amalloyi suspect
16:57amalloyso when you want to call a no-arg "method", i'd play safe with (. x (play))
16:59Blackfootamalloy: thanks, that worked. i haven't used the unsugared notation before
17:00kephaleamalloy: not in a macro but ##(concat '(a b c) (when true ['x])) ##(concat '(a b c) (when false ['x]))
17:00lazybot (concat (quote (a b c)) (when true [(quo... ⇒ (a b c x)
17:00lazybot (concat (quote (a b c)) (when false [(qu... ⇒ (a b c)
17:00Blackfooti wonder if it could eventually tell that it was a function
17:00kephaleerr, i need to learn lazybot...
17:00amalloyBlackfoot: 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:01PupenoI got La Clojure working beautifully… documenting how now.
17:01kephalei'm not sure if you can get anything smaller than what you have, but concat would hide that nil for you
17:01amalloykephale: the ~@ stuff is basically the same as that concat
17:02amalloyi just feel like there should be an append-if function or something like that. maybe i should just write it
17:04kephaleamalloy: that does sound like the best way to make it anymore readable without bloat
17:04kephaleany more*
17:05Blackfootamalloy: that doesn't seem to be what http://clojure.org/java_interop indicates is the JVM behavior
17:05amalloyIf 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:06Blackfootamalloy: yea, isn't 'play' a no arguement public method?
17:06amalloyno, it is a field, which happens to be a function
17:06amalloyin java, trying to access a method as a field is an error
17:06amalloyso the compiler special-cases that
17:06amalloyin js, it's perfectly fine
17:06Blackfootso javascript doesn't have any methods, basically?
17:07amalloyi mean, i'm not a js expert, so that's probably oversimplifying, but yes
17:07dnolenBlackfoot: 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:08dnolenBlackfoot: but no, "methods" are not an actual construct of the language.
17:08Blackfoothmm, so would ((.play (FadeOut ...)) work? trying...
17:08amalloyprobably
17:08Blackfooti'm not a js expert either, just playing around with clojurescript. pretty cool stuff
17:09Blackfootguess not... Uncaught TypeError: Object [object DOMWindow] has no method 'onBegin'
17:10Blackfootgenerates (new goog.fx.dom.FadeOut(counter__1996,1000)).play.call(null)
17:10Blackfooti'm not familiar with the call() function
17:10dnolenBlackfoot: "this" was not set.
17:10dnolenBlackfoot: all functions have a call property which allows to do 2 things
17:10dnolen1) set the value of 'this' 2) pass the args
17:11dnolen.call(object, a0, a1, ..., an)
17:11dnolenin your case object was probably set to null
17:12Blackfootyea looks like it
17:14dnolenBlackfoot: in anycase (. x (play)) is what you want because of in JS you just have properties.
17:14Blackfootyep, that is working. I like learning about the reasons why, too, thanks for the explanations
17:36kyleburtonhello
17:37kyleburtonanyone 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:37kyleburtontrying to load a file, I get that exception
17:39hiredmanyour swank-clojure isn't really up to date, double check
17:41duncanmhow that i program in JRuby, i really appreciate the Clojure reader decision to require explicit forward declarations
17:41kyleburtonthank you - Technomancy responded on #leiningen
17:42kyleburtonI 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:42kyleburtonthanks!
17:57RaynesI 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:57RaynesNot that it matters. The repository was private, so there weren't any watchers to propagate.
19:01momoxwhat does this line of code do? http://pastebin.com/sdCAhDPq
19:01momoxits part of the source code of conj
19:01amalloyit calls clojure.lang.RT.conj
19:01amalloywhich is in java
19:02hiredmanclojure.lang.RT/conj
19:06momoxamalloy: i can't view the source from the repl?
19:07hiredmanit's a java method
19:09momoxhiredman: so the only way to view it is to open the .java file using a text editor?
19:09hiredman*shrug* whatever floats your boat
19:10amalloyother ways include: looking at the .java file on github
19:13momoxgood idea
19:13momoxthanks hiredman and amalloy
19:19momoxit looks like that line of code will keep on calling itself over and over again
19:19momox(conj coll x)
19:20hiredmanhttp://clojure.org/java_interop
19:25the-kennyThanks for implementing Multimethods in ClojureScript. Makes my life so much easier :)
19:25dnolenmomox: the Clojure code is calling out to Java to do the actual work.
19:26dnolenthe-kenny: did multimethods get merged to master?
19:26the-kennydnolen: Yup
19:29momoxdnolen: thanks. I understand it now. Just realised that (. Classname-symbol (method-symbol args*)) is equivalent to (. Classname-symbol method-symbol args*)
20:15pmbauer[ANN] First Clojure User Group Meeting. https://groups.google.com/d/msg/clj-phx/l_S4qcOSuaY/WhOC7T8HOK8J
20:15pmbauerPhoenix, AZ
20:15pmbauerhttp://clj-phx.wikispaces.com/
20:15pmbauerThat is all, thank you!
20:27dnolenpmbauer: cool!
20:31PupenoHere's how I got La Clojure working: http://pupeno.com/blog/getting-started-with-la-clojure-on-mac-os-x-a-visual-guide/
20:33hiredmanwell there is your problem right there
20:33hiredmanusing the system package manager to install clojure
20:35hiredmanyou should be fetching it from a maven repo via lein/maven
20:54tauntaunNewbie Q: Any reason why I can't (import '(javax.swing SwingUtilities)) in Clojure, seeing as I can import it in Java?
20:55hiredmanwhat makes you think you cannot import it?
20:55tauntaunNevermind :) It was a typo...
21:18dnolenman i love metadata on symbols.
21:25dnolenif 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:27hiredmandnolen: "3 or 4" means it depends on the ordering?
21:27dnolenhiredman: yeah. those are ambrose notes.
22:58sritchiehey 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:58sritchieI'm trying to get a feel for how these web stacks incorporate their js
23:08gfrlogsritchie: that sounds like a pretty tame use case to me
23:09sritchiehaha, sure, I get that
23:11gfrlogum. so yes it makes sense?
23:11sritchieI 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:12Scriptorsritchie: that's more of a choice in what you want your app to be like
23:12Scriptorif 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:12Scriptorand have something like sinatra on the server
23:12sritchieI see
23:13sritchieso a more complicated data model would push toward a need for a bigger web framework to back clojurescript
23:13Scriptornot really
23:14Scriptorwhat 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:14sritchieI'll lay out what I'm thinking -- I'm designing a registration system for kayak regattas
23:14sritchiethese 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:16sritchiebeyond that, athletes are members of teams, which have their own area within the site
23:16sritchieI'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:17Scriptorhmm, it's not really a matter of clojurescript vs rails
23:17Scriptorkeep in mind that the niche clojurescript is meant to be an alternative to something like dojo, extjs, or yui
23:17Scriptorbasically, heavyweight js frameworks
23:18Scriptorit's perfectly fine to have clojurescript and rails at the same time
23:18Scriptorjust like you can have dojo and rails at the same time
23:19sritchiegreat, this gives me a good place to start absorbing
23:21goodieboywhat is "&" in clojure? for example when using defn to specify optional arguments...
23:22sritchiegoodieboy: & packs all optional arguments (if they exist) into a list bound to the var following &
23:22Scriptorin 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:22amalloyargh don't encourage him to think of it as "optional"
23:23amalloy"additional", or "further" or something. "optional" implies, among other things, that you could put multiple bindings after the &
23:23sritchieamalloy: good point, sorry about that
23:23amalloyjust the other day someone was asking why (fn [x & y z]) didn't work
23:24amalloyanyway, Scriptor's definition is good
23:25leonid_is there a way to define a var arg function using #()?
23:25amalloy%&
23:25leonid_!
23:26leonid_thanks !
23:26amalloyclojure and perl: members of a small group of languages in which you can answer a question using only punctuation
23:26goodieboyok 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:27amalloygoodieboy: mostly, it's just defn (actually, it's destructure, which is used by fn and by let)
23:28amalloyi learned recently that that's a bit of a simplification, but i didn't encounter any of the exceptions for over a year
23:29goodieboycool ok thanks... coming from ruby, this homoiconic stuff is fascinating :)
23:29amalloy(and when i did, i was doing something evil. so you shouldn't worry about it)
23:30amalloyspecifically, it turns out you can't define a macro named &
23:30amalloybecause the reader refuses to macroexpand it
23:30goodieboyoh really? so it is something "special"?
23:30goodieboyahh ok
23:30amalloylike i said, there are some exceptions
23:30amalloybut you won't see them unless you're evil
23:31goodieboyok good to know. well, i am not evil, but wish i were :)
23:32amalloywell, 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:32amalloyjeez that's a stupidly long url
23:33goodieboywow 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:36goodieboyha ha, the last comment is the best
23:56rimmjob_is there a list of differences between clojure and emacs lisp ?
23:56luccaindirectly
23:56amalloydifferences (1) they are very different
23:56amalloy(2) see 1?
23:57luccahttp://clojure.org/lisps might help
23:57luccadepending on how well you know elisp
23:57rimmjob_thankee
23:58amalloylucca: 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:58hiredmanthe docs are from the last release (1.2.x)
23:59amalloyor...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