#clojure log - Sep 21 2011

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

4:03 Fossi: i found a bug in the ring cookie parsing (it's simply broken with large cookies). anybody know where i could post the testcase/report?

5:08 thorwil: Fossi: since the github page has no Issues, i guess http://groups.google.com/group/ring-clojure

5:15 Fossi: thorwil: thanks, will post

5:24 fliebel: Doesn't cake understand :source-path?

5:33 michaelr525: hello

5:51 scottj: fliebel: there's a cake channel, #cake.clj I think

6:31 terom: Anybody with experience of different CSV libraries for Clojure or Java; any recommendations what library should I use? There seems to be quite many options available (clojure-csv, data.csv, OpenCSV...)... (I'm beginning to write a small application which is going to read few small CSV files and write data to an XML file.)

6:50 clgv: terom: if you get no other answer try those you found. if those dont suit you, you could also write an own abstraction since CSV is pretty easy structured.

7:51 lnostdal: some user defined macros seem to indent proper, while others do not; i suppose this has something to do with naming .. how does one get slime (clojure-mode?) to indent macros with custom names(?) proper too?

8:05 joegallo: (eval-after-load 'clojure-mode '(add-hook 'clojure-mode-hook (lambda () (put-clojure-indent 'your-macro-here 'defun))))

8:05 more or less

8:06 that'll handle the indenting, but not highlighting like a keyword (which is nice for macros)

8:07 for the highlighting, you'd want a similar callback, or just use the same one, and this inside:

8:08 (font-lock-add-keywords 'clojure-mode '(("(\\(your-fn-here\\)" (1 font-lock-keyword-face))))

8:08 again, more or less

8:11 Blkt: good afternoon everyone

8:12 mdeboard``: morning

8:13 Blkt: could anyone explain me whythis code always returns nil?

8:13 (loop [k '(1 4 7 10 13) acc '()]

8:13 (cond (< 2 (count k)) acc

8:13 :else (recur (drop 2 k) (cons (take 2 k) acc))))

8:13 opqdonut: since < should be > ?

8:14 mdeboard: ,(acc '())

8:14 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: acc in this context, compiling:(NO_SOURCE_PATH:0)>

8:14 clgv: and it returns '() and not nil ;)

8:14 mdeboard: oh

8:14 Blkt: I suppose that means that I'm a bit tired...

8:14 should eat something

8:14 opqdonut: ,'()

8:14 clojurebot: ()

8:14 mdeboard: So, recur just has to be in the tail position for the loop, not the whole function?

8:14 * mdeboard rubs his beard

8:15 opqdonut: mdeboard: recur needs to be in tail position wrt. the recur point

8:15 mdeboard: opqdonut: Got it

8:15 opqdonut: which is the innermost loop/function/thing

8:15 mdeboard: thanks

8:15 opqdonut: think of loop just as defining a recursive helper function and calling it right away

8:16 Blkt: thanks for the help

8:16 mdeboard: I don't why I was thinking it had to be in absolute tail position, guess that means taht I'm a bit tired...

8:19 clgv: mdeboard: in the above example it also is in "absolute" tail position provided I interpret that term right

8:19 mdeboard: yeah absolute to the outer context

8:19 outer scope*

8:20 lnostdal: joegallo, thank you!

8:20 clgv: mdeboard: in fact to the whole expression

8:21 mdeboard: clgv: How so? `acc` is in the tail position

8:21 clgv: mdeboard: there are two tailposition due to the branching via cond.

8:22 mdeboard: clgv: Maybe I misunderstand what tail position is then...I'll googe.

8:23 manutter: tail position means that the function does not do any further processing on the results of the call to recur

8:23 clgv: mdeboard: one keypoint is that you are not allowed to modify the result of the recursive call.

8:23 mdeboard: manutter: Ok, I think that's clear enough. I was making it more complicated

8:25 manutter: I suppose I should say "the loop or function does not do any further processing"

8:25 but that's the main point

8:56 khaliG: is there a good reason to seperate model and view (swing) in clojure?

8:58 manutter: probably.

8:58 :)

8:58 Is there something you'd rather do instead of keeping them separate?

9:00 khaliG: manutter, yea, not :) i'm just getting fed up abusing closures

9:01 manutter: I've always heard of MVC in connection with OOP, but I can't see any reason why it would be tied to OOP specifically

9:02 are you sure it's "abuse" and not "idiom"?

9:04 khaliG: manutter, honestly, I don't see the difference between the two :/

9:04 manutter: Heh

9:04 If it's your own personal project, might be interesting to experiment with the alternatives

9:05 if MVC is a valid design principle, then you'll start having problems with changes to your model forcing cascading changes to your views

9:05 but I have to say in my experience a change in the model tends to have that effect anyway

9:08 khaliG: i might experiment - can't be any worse than what i've got so far :P

9:22 pyninja: Question about clj-http: any reason why `curl https://someurl -d "a=b&c=d&..."` might be different than `(http/post url {:query-params data :headers {"Content-Type" "application/x-www-form-urlencoded"}})`? Curl is working, clj-http is not.

9:24 could it be an SSL issue?

9:24 dakrone: hey are you around?

9:26 manutter: pyninja: what results do you get from clj-http?

9:26 pyninja: manutter: well i can't really tell what request clj-http is actually making (is there a way to see that?), but I'm trying to send a request to an API (paypal :(), and it's giving an error. But the equivalent curl code is working fine.

9:27 manutter: what's the error?

9:27 pyninja: manutter: i mean it's a paypal error - "timeout processing request". not very helpful...

9:27 manutter: (heh, I'm planning on using clj-http to send a "curlish" request to paypal myself, as soon as I get home, so this is very interesting to me)

9:28 pyninja: heh

9:28 i'm suspecting it's an SSL thing probably, since Paypal's PHP sample code seems to be turning off SSL verification.

9:29 I wonder if there's a way to disable SSL verification in clj-http...

9:29 manutter: yeah, sounds plausible

9:35 Blkt: how do I create a Double[] from a sequence?

9:35 I need to feed it to class method

9:40 clgv: Blkt:## (doc double-array)

9:40 &(doc double-array)

9:40 ,(doc double-array)

9:40 clojurebot: "([size-or-seq] [size init-val-or-seq]); Creates an array of doubles"

9:41 joly: ,(double-array [1 2 3])

9:41 clojurebot: #<double[] [D@1fd9ce4>

9:41 clgv: ,(seq (double-array [1 2 3]))

9:41 clojurebot: (1.0 2.0 3.0)

9:42 Blkt: thanks a lot clojurebot

9:42 er...

9:43 thanks a lot clgv

9:45 clgv: Blkt: there are more like this for e.g. int

9:45 pyninja: manutter: so yeah it looks like actually ssl is not the issue. i enabled ssl verification in their php sample code, and it still works.

9:46 Blkt: clgv: I just noticed it by M-. double-array

9:48 manutter: pyninja: I'll have to play with it tonight when I'm at my main clojure pc

9:49 clgv: manutter: "clojure mainframe" ? ;)

9:49 manutter: heh, just about :)

9:49 choffstein: Does anyone here use JodaTime or clj-time? I'm having serious issues trying to parse strings that have time-zones … which JodaTime says it can't parse

10:03 khaliG: choffstein, yes, do you have an example pasted somewhere?

10:04 choffstein: Nothing complex. Basically, I have getting strings that are in "E MMM d HH:mm:ss zzz yyyy" format, but when I try to createa custom formatter and then parse a string in that format, clj-time crashes with a "can't parse Time Zone"

10:05 (use '[clj-time.format]) (def custom-format (formatter " MMM d HH:mm:ss zzz yyyy")) (parse custom-format "Wed Sep 21 00:00:00 EST 2011")

10:06 dbushenko: which is the most correct way to start slime session: slime-connect or clojure-jack-in?

10:06 choffstein: Err, (formatter "E MMM d HH:mm:ss zzz yyyy")

10:06 manutter: dbushenko: depends if you've done "lein swank" at the command line

10:07 clojure-jack-in starts swank for you

10:07 dbushenko: manutter, I don't use emacs-starter-kit, so probably my clojure-mode differs a bit

10:07 but when I try to connect with slime-connect

10:08 emacs doesn't open the repl

10:08 clojure-jack-in opens the repl and works fine

10:08 what's wrong with slime-connect?

10:09 manutter: dbushenko: I don't use emacs starter kit either, just clojure mode and swank-clojure

10:09 are you starting swank with lein swank or something equivalent?

10:09 scottj: dbushenko: did you start swank with lein swank?

10:09 dbushenko: manutter: what package manager and clojure-mode version do you use?

10:09 scottj, sure

10:10 manutter: I'm not sure, but the latest version of each, as far as I know

10:10 dbushenko: manutter, yep, but there are different package managers for emacs, as I know

10:10 which one do you use?

10:10 manutter: do you have a *swank* buffer in emacs? Might be some interesting info there if so

10:10 scottj: dbushenko: look in Messages or *slime events* etc for some error message

10:11 dbushenko: manutter, no, *swank* doesn't open

10:12 scottj, Connecting to Swank on port 4005.. [2 times]

10:12 error in process filter: slime-intern-indentation-spec: Wrong type argument: listp, 1

10:12 error in process filter: Wrong type argument: listp, 1

10:12 seems like this is all of the errors

10:13 manutter: hmm, yeah, sounds like some kind of version conflict between different libraries.

10:14 dbushenko: so which versions do you use?

10:15 manutter: I basically wiped out my old stuff and followed the instructions at https://github.com/technomancy/swank-clojure

10:15 dbushenko: technomancy, hi, I do exactly as described in https://github.com/technomancy/swank-clojure

10:15 but only clojure-jack-in runs, slime-connect doesn't open the repl

10:16 is that ok or I've done something wrong?

10:16 manutter, OMG, I did exactly as described there....

10:16 what could that be?

10:17 manutter: hmm, I'm running out of clues, my only guess is maybe some old libs still hanging around inside .emacs or .emacs.d?

10:18 scottj: M-: (slime-changelog-date)

10:19 actually not sure if that works with elpa version of slime

10:19 dbushenko: ok, thank you guys, I'll try emacs 24

10:19 bye!

10:23 khaliG: choffstein, yeah i see what you mean. Perhaps you might parse the date without the EST and then convert it to the correct TZ using to-time-zone?

10:23 choffstein: khaliG: That might be an option, but I don't think the string will parse since I have the time zone in there. I suppose I could split the string using space as a sep, remove the time-zone element, and smush it back together -- then parse. But that seems … ugly

10:25 khaliG: choffstein, yep you'd have to preprocess the string before hand, agreed it's not as nice

10:27 choffstein: khaliG: i'll give it a whirl. might not be sexy, but it might get the job done

10:28 khaliG: choffstein, sounds good :)

10:29 bsod1: hi, I'm trying to install counterclockwise eclipse plugin for clojure development but I'm getting this error message: http://paste.pocoo.org/show/479913/ (on eclipse indigo) . can anyone help me?

10:29 clojurebot: clojure bot is not immune to ,(iterate inc 0)

10:32 terom: bsod1: make sure you're using the correct update site (http://ccw.cgrand.net/updatesite)

10:34 Wiki page for installation has some older update site which is not in use, probably

10:34 bsod1: terom: great, thanks

10:48 clgv: bsod1: yeah 0.3.0 is latest CCW version

10:48 bsod1: clgv: is it compatible with eclipse indigo? repl is not working. also clojure perspective is not added.

10:49 clgv: bsod1: yes I have CCW 0.3.0 workin on 3 machines with eclipse indigo

10:49 no special magic was need to get it running

10:50 bsod1: clgv: ok I'm installing again

10:50 clgv: if you have any old version, get rid of it before installing the new one

10:50 bsod1: no I didn't have any old versions

10:53 scottj: can protocol methods have vargs?

10:53 choffstein: Anyone know a way to drop the nth item in a sequence?

10:53 I suppose I could index the items then filter … but that just seems ugly

10:54 clgv: scottj: no they cant

10:54 pdk: (doc drop-nth)

10:54 clojurebot: It's greek to me.

10:54 clgv: but you dont get an error in clojure 1.2 and the '& is interpreted as param name

10:55 scottj: clgv: ty

10:57 choffstein: alright. gotta run. have a good one everyone

10:59 bsod1: clgv: I've uninstalled and installed again but still same, can't run REPL and clojure perpective isn't added

11:00 clgv: bsod1: so what did you do after installing? did you create a clojure project?

11:00 bsod1: yes

11:00 manutter: bsod1: other plugins installed?

11:00 bsod1: manutter: no, just standart eclipse indigo

11:01 manutter: erm, and viPlugin

11:01 clgv: bsod1: there is no clojure perspective yet, but there are several views

11:01 bsod1: you'll get a repl by running a clojure file of your project

11:02 bsod1: clgv: wait, I opened REPL view and can run commands now

11:02 clgv: ok ok, I think all I need was to open a REPL view. but it still strange that when I run "load this file to REPL", I get an error message

11:03 clgv: also, is there a way to disable rainbow parens?

11:04 clgv: bsod1: why would you want to disable coloring of parens?

11:05 whats the error message? the ctrl+alt+s works well here

11:05 bsod1: clgv: looks bad, it already highlights it's pair when I move cursor on to a paren

11:06 clgv: hmm, looks like after opening REPL view, ctrl+alt+s works

11:07 clgv: do you know any must-know hotkeys for counterclockwise? like `show documentation`?

11:07 clgv: ctrl+alt+n is useful to switch the repl to the namespace of the file you are in (when changing the file after starting the repl)

11:09 TimMc: C-M-n, you mean

11:09 kzar: If you're dealing with large XML files what's a sensible way to go about it? Just clojure.xml/parse and then map over it? I tried using clojure.xml/parse and it seems to take absolutely ages - the file is 5 megs though.

11:10 clgv: bsod1: the outline view is also nice

11:10 bsod1: clgv: can you look at my REPL view? something wrong, it's not working http://ompldr.org/vYWduNg/counterclockwise.png

11:10 clgv: TimMc: no I do not

11:11 TimMc: You don't?

11:11 clgv: bsod1: seems you killed the nrepl server. the view still stays alive

11:12 bsod1: you kill the nrepl server via the "terminate" button in the console view, but that doesnt close the repl view

11:14 bsod1: solution => just close the old view and restart a repl

11:15 * manutter really hates the layout @clojure-toolbox.com :P

11:17 kzar: Oh it looks like this might do what I want. https://github.com/marktriggs/xml-picker-seq

11:18 simard: I have a function f1 that should take a list as argument and apply a function f2 to its elements, only if the element is a {}. if the element is itself another list, it should instead call f1 on it. what's the most idiomatic way of doing that ?

11:19 clgv: simard: examples! *got a knot in my head reading the description*

11:23 simard: ok: (draw (list {:a 1} (list {:a 2} {:a 3}) {:a 4})) should yield (f2 {:a 1}), (draw {:a 2} {:a 3}) and (f2 {:a 4})

11:23 and that draw should yield (f2 {:a 2}) (f2 {:a 3})

11:24 bsod1: clgv: I've tried reopening REPL view but didn't work, I restarted eclipse and still the same, something wrong with this REPL view

11:27 clgv: bsod1: no. you have to restart a repl! not the view.

11:28 joly: simard: maybe something like (defn draw [xs] (doseq [x xs] (if (map? x) (f2 x) (apply draw x))))

11:28 clgv: bsod1: the view is only a nrepl client which needs an nrepl-server that is started when you do ctrl+alt+s or F9 (run) in a file

11:30 bsod1: clgv: do you mean this? http://ompldr.org/vYWducA

11:30 manutter: eclipse is too complicated, I'm sticking with something easy like emacs.

11:30 clgv: manutter: roflmao!

11:30 Bronsa: lol manutter

11:31 manutter: sry, couldn't resist :)

11:32 clgv: bsod1: just close that repl view, go to the console view and terminate all running processes. then click into your test1.clj and select "run" from the menu

11:32 simard: joly: hum that doesn't actually build a tree out of the return values of draw does it ?

11:32 it's just for side effecs

11:32 effects*

11:33 joly: can change doseq to for if you want the results back

11:33 bsod1: clgv: I have nothing in console view :)

11:33 joly: simard: ^

11:33 simard: oh :)

11:33 thank you

11:33 joly: sure thing :)

11:34 bsod1: clgv: do you want a screenshot :)

11:34 clgv: bsod1: ah hm. your source folder is displaying an error. you should have a look at that

11:34 bsod1: clgv: really? it's a java project(actually java standart api source code from oracle JDK)

11:34 clgv: bsod1: what? didnt you create a clojure project?

11:35 bsod1: clgv: clojure_test project is clojure project, and test1.clj is in it

11:35 clgv: bsod1: ah k that is another project :P

11:36 bsod1: clgv: :) I just created a new clojure project and now everything is working :) I think the problem was when I remove counterclockwise to reinstall, something went wrong about old project

11:37 clgv: thanks

11:37 clgv: bsod1: yeah I guess there is no backwards compatibility between 0.0.64 and 0.3.0 ;)

11:42 simard: shouldn't that produce a multiline string with numbers from 1 to 10 ? (with-out-str (map println (range 1 10)))

11:42 clgv: ,(with-out-str (map println (range 1 10)))

11:42 clojurebot: ""

11:43 simard: ,(with-out-str (println 10))

11:43 clojurebot: "10\n"

11:43 clgv: simard: ah lol. the lazy map gets evaluated outside the with-out-str

11:43 ,(with-out-str (doall (map println (range 1 10))))

11:43 clojurebot: "1\n2\n3\n4\n5\n6\n7\n8\n9\n"

11:44 simard: clgv: even when I enclose it with a (spit ...), it doesn't work

11:44 clgv: simard: it only prints to the string within the with-out-str form but the evaluation of the lazy map does not take place in there

11:44 simard: oh

11:45 makes sense

11:45 tricky :)

11:45 clgv: ,(doall (with-out-str (map println (range 1 10))))

11:45 clojurebot: ""

11:45 clgv: see above ^^

11:45 simard: you can use doseq for side effects

11:46 ,(with-out-str (doseq [i (range 1 10)] (println i)))

11:46 clojurebot: "1\n2\n3\n4\n5\n6\n7\n8\n9\n"

11:49 simard: is there a function that combines (doseq) and (flatten) ?

11:49 like... dotree

11:50 clgv: simard: not that I know of. just put the flatten call where range was in the example

11:50 or do you need traversing in a certain order?

11:51 simard: clgv: linear order, so flatten will do

11:51 kzar: I've added [org.clojure/clojure.contrib "1.2.0"] to my deps in project.clj but now `lein deps` is failing to grab the pom. Pretty sure I'm doing it right, any ideas?

11:52 clgv: kzar: [org.clojure/clojure-contrib "1.2.0"]

11:52 minus instead of dot

11:52 kzar: ah balls, thanks clgv

11:53 hugod: anyone know of a way to get the current test var within an :each fixture in clojure.test?

12:11 Blkt: cya tomorrow everyone

12:13 jli: I have a file with tens of thousands of lines in it, each line is short (say <50 chars). I'd like to build an index from each line in the file to the line number. I have something, but it seems slow

12:14 basically: (zipmap (line-seq (clojure.java.io/reader file)) (map inc (range)))

12:19 clgv: jli: what will you do with the index?

12:19 kzar: How do you have `lein deps` grab Java libraries that aren't hosted on Clojars?

12:19 I wanted to use nu.xom.Document

12:20 clgv: kzar: you can specify repositories, see the example on leiningens github page

12:22 joegallo: i think that you won't even need to do that, xom is already on maven central, which i'm pretty sure is in the list of default repositories

12:23 but i could be wrong, of course

12:23 clgv: joegallo: might depend on the leiningen version.

12:24 joegallo: good point

12:24 clgv: but I think I remember it being on the list

12:25 I got swingx via mavencentrel

12:25 joegallo: seems to work as i thought here with leiningen 1.6.1

12:28 clgv: Ihave

12:34 arohner: repo support was added to lein a long time ago, like 1.3 or 1.4, you should have no problems with that

12:34 kzar: make sure your dependency is written correctly, that's where most problems occur

12:37 kzar: arohner: Yea I just had no idea how to go about it. Thanks to the tips I've made a bit of progress though, I found it on the maven core website and from that could add it to my project file

12:38 joegallo: http://mvnrepository.com/

12:38 i usually just search for the library name here, and it spits out something usable, the 75% of the time the website is up at all

12:57 zippy314: in clojurescript, whats the right way to convert a string to an integer?

12:58 malkomalko: hey all, is there a way to force a reload of your clojure files in a repl? I know you can do a specific ns by adding :reload, but is there anyway to reload all dependencies of a file?

13:02 hugod: :reload-all

13:05 malkomalko: wonderful!

13:14 dnolen: zippy314: js/parseInt, Google Closure probably has something as well.

13:14 zippy314: dnolen: thanks! I just figured out the js namespace. Not very well documented!

13:22 simard: I need to have a global variable *point* (a [x y] couple) that I want to change from within a few select functions, what is the best strategy to use here ? a ref ?

13:23 ie.: it seems vars won't do because I don't want lexical scope binding but permanent change of the value stored in *point*

13:23 drewr: an atom may suffice

13:23 no earmuffs

13:26 hiredman: or even better, pass in the function you need to where you need it

13:27 (binding [*function-to-map* inc] (map (range 10))) ;; kind of silly

13:27 srid: i ran (run-jetty ...) on REPL (emacs swank), and now it hangs for ever. is it possible to interrupt this function alone, without restarting swank?

13:27 hiredman: C-c C-c

13:27 srid: alternatively, is there a way to launch the server and return immediately.

13:27 hiredman: yes

13:27 read the docs for the function

13:27 srid: that works, thanks

13:30 :join? and defonce will work, http://stackoverflow.com/questions/2706044/

13:34 hiredman: srid: having a (defonce server (run-jetty ...)) in the middle of your source file is a bad idea, means jetty will be launched anytime the file is evaled/compiled

13:35 you should have a function that starts the server, and just call that function at the repl when you want to start a server

13:36 srid: hiredman: i defonce in repl. but now i'm inclining to use ring's "ring server"

13:36 hiredman: from lein ring?

13:36 srid: yes

13:36 hiredman: it's a nice plugin

13:36 srid: it auto restarts on file change.

13:39 here's my simple aleph http server (wrapped in ring) https://gist.github.com/1232768 - it is throwing an IllegalArgumentException (No implementation of method: :consumer of

13:39 ; protocol: #'lamina.core.channel/ChannelProtocol found for class: nil) ... any idea why?

13:40 hiredman: I imagine protocols don't play nice with lein-rings reloading

13:51 srid: hiredman: seems so. not using lein-ring fixes the issue

13:51 hiredman: is there a workaround, so I can still use lein-ring? (i haven't read about protocols and records yet)

13:53 hiredman: not really

13:58 srid: the streaming requests example from aleph doesn't work at all.

13:59 maybe i should stop relying on beta software to get something up and running today

14:21 zippy314: here's a closure issue with clojurescript. Check out this simple example https://gist.github.com/1232866 which adds in some new elements and (I thought) a listener for each of them which responds differently depending on which one is clicked. What actually happens is that the value of hid in the anonymous function will simply be the last value from the doseq list. Is this a bug in clojurescript?

14:23 manutter: zippy314: no, that's plain old js closure

14:23 you need a function that takes hid as an argument, and returns the anonymous function you've got there

14:28 zippy314: manutter: Hmm yah. I just updated the gist with what you said and it works. But shouldn't the clojurescript compiler detect this case and insert an anonymous function like that?

14:29 manutter: you might not always want it to :)

14:32 the compiler is behaving correctly, you just have to understand function scope and how to use it

14:32 since hid was a var outside the scope of the anonymous function, all the anonymous functions you created referred to the same "hid"

14:33 by making a function that took hid as an argument, and returned an anonymous function, each anonymous function got its own unique value of hid

14:34 pandeiro: Should ClojureScript always follow the prototype chain when dealing with objects with inherited properties and methods?

14:35 I want to call preventDefault on an event but it's saying the method doesn't exist

15:20 carllerche: is there anyway to dispatch a protocol on a byte array?

15:21 kjeldahl: Anybody have any pointers to using jdbc with a persistent connection, i.e. not using with-connection, but rather some variant of get-connection?

15:25 Never mind; with-connection uses get-connection, and I guess a "top-level" with-connection neatly solves it.

15:25 dnolen: carllerche: yes, http://dosync.posterous.com/51626638

15:32 carllerche: dnolen: huh that's interesting

15:32 you can extend types at runtime? i did not know that

15:37 ibdknox: dnolen: I have bad news on the cljs perf front

15:40 mattmitchell: anyone here use midje?

15:41 fdaoud: mattmitchell: have took it for a spin but that's it

15:42 khaliG: so i'm using (fn [&{:keys [...]}] for keyword arguments and wondering if there is a way to access the arguments programatically inside the function, something like (doseq [a args] (if a ...)) - is this possible?

15:42 mattmitchell: fdaoud: what'd you think?

15:43 fdaoud: mattmitchell: looks nice, will go back to it but for now clojure.test satisfies my needs

15:43 mattmitchell: fdaoud: cool thanks

15:49 dnolen: ibdknox: what in particular? I've done a few tests myself.

15:49 ibdknox: dnolen: iterating over anything is incredibly slow

15:49 dnolen: as in 3-4 orders of magnitude slower than native JS

15:50 fdaoud: mattmitchell: have you tried it?

15:51 dnolen: ibdknox: ah yeah, to be expected at this point - 3-4 orders slower doesn't really make much of a difference when you're dealing w/ common client side JS operations.

15:51 mattmitchell: fdaoud: Yes we use it for all of our tests. I'm curious to see if others are using it, and what their experiences are.

15:51 ibdknox: dnolen: matters if you want to do any canvas rendering

15:51 dnolen: ibdknox: that said I think there's a place for amap, areduce, etc. in ClojureScript which compiles down to more efficient operations.

15:52 fdaoud: mattmitchell: interesting. do you do mocking with it? that would be my primary interest.

15:52 dnolen: ibdknox: could that be solved for your usecase w/ amap/reduce ?

15:52 the-kenny: Aren't closures supported in ClojureScript? I see the following behavior in repljs: https://gist.github.com/1233113

15:52 mattmitchell: fdaoud: we do yes, works pretty well actually

15:53 ibdknox: dnolen: an efficient doseq would cover everything for me

15:53 dnolen: the one other place it would be nice amap would be perfect

15:53 fdaoud: mattmitchell: great, thanks

15:53 dnolen: the-kenny: you're just seeing a oddity of REPL output, that works as advertised.

15:54 kjeldahl: Using the jdbc with-connection (which closes connection after executing) seems terribly inefficient. Any better methods, or hints about why my assumption is wrong?

15:54 the-kenny: dnolen: Ah, okay :) Thanks

15:54 fdaoud: kjeldahl: use a connection pool perhaps?

15:56 joegallo: yeah, seriously, get c3p0 or something behind it and you'll be rockin'

15:57 kjeldahl: fdaoud: Pointers? I'm finding something about apache dbpc, but that's yet another abstraction, which need yet another clojure interface I guess. Anything simpler (reusing a single connection or similar, disregarding obvious challenges about synchronizity which may or may not be handled by the driver)?

15:58 Easier than I though I guess: https://gist.github.com/470904

15:59 fdaoud: kjeldahl: like joegallo I'd recommend c3p0 http://www.mchange.com/projects/c3p0/index.html

15:59 dnolen: ibdknox: looking at the implementation of ISeq for arrays. Have you benched loop/recur ?

15:59 ibdknox: dnolen: not yet, does it look like it might be more efficient?

16:03 dnolen: ibdknox: yes it looks more efficient, one things that's missing for ClojureScript to be really fast for Canvas like stuff is inlining.

16:04 kjeldahl: fdaoud/joegallo: Thanks, I will have a look at it. It does seems that dbcp has some clojure hand-holding already however; http://clojars.org/org.bituf/clj-dbcp , but if c3p0 is the way to go in the java world I guess I need to look into it.

16:04 dnolen: worth bringing up on the ML to see if we can move forward on that, especially since you could benefit from it now.

16:05 ibdknox: dnolen: yeah

16:06 dnolen: I'll throw together some stuff on my findings.

16:07 dnolen: ibdknox: that would be awesome.

16:09 ibdknox: actually doseq expands to loop/recur so I think you're paying for the indirection of function calls when you really want inlining.

16:10 ibdknox: dnolen: yeah, that's what I assumed was killing me. I think a single (doseq [n [1 2 3]] ) ends up making a ridiculous number of function calls

16:10 all done with apply, which I believe slows it down even more

16:11 dnolen: ibdknox: hmm I'm not so sure about the apply part.

16:11 ibdknox: dnolen: to give you an idea of what I was seeing, a for loop in native JS over 1,000,000 elements took 1-4ms to complete

16:11 dnolen: in cljs it was around 3.5-4s

16:12 dnolen: ibdknox: I know, I've seen the same things. I've been focusing on DOM related things so those things haven't bothered me much yet.

16:12 you can't even write keys in localStorage faster than 5000 kv pairs / sec :P

16:12 ibdknox: lol

16:13 well, perhaps a less contrived scenario was me trying to render tiles in a game. only 144 elements, but it was taking longer than the render-loop's execution time

16:19 choffstein: Anyone want to test a lein plugin I wrote? :D https://github.com/newfoundresearch/lein-clj-doc-test

16:19 dnolen: ibdknox: the challenge here is that we can't just inline the function + into something better like you can on the JVM (which eliminates the method call overhead quite well) ...

16:21 ibdknox: dnolen: I know.. I thought a little bit about it and I think this is actually going to be really complicated to solve. I'm not entirely sure the solution exists at the CLJS compiler level. I think it might actually have to be a pass over the generated JS itself, which would be a *lot* of work

16:21 dnolen: ibdknox: nah, we just need to find out how disdained js* really is.

16:21 ibdknox: lol

16:22 dnolen: ibdknox: if it is disdained then something else is needed that accomplishes what it does.

16:23 Raynes: cemerick: I didn't know you were doing another fundraiser! Cool stuff.

16:23 ibdknox: dnolen: So your thought is for certain constructs (loops in this cases), we explicitly write the JS it should output?

16:23 Raynes: I'm surprised I missed all the tweets about it.

16:24 dnolen: ibdknox: no doseq does the correct thing.

16:24 what's wrong is that artithmetic primitives are fn calls and not inlined into JS +, -, /, *, <=, etc.

16:26 cemerick: Raynes: Yup; seemed like something worth repeating, as much as that's possible. :-)

16:27 putting it out there during the conf ended up not being a fantastic idea.

16:27 There was only one way to see what would happen, tho.

16:30 dnolen: speaking of which please all, retweet this - https://twitter.com/swannodette/status/116610530575269888

16:30 cemerick: ^

16:31 cemerick: dnolen: thanks :-)

16:33 renjikken: I have installed clojure and clojure.contrib via aptitude and am able to run clojure via the 'clojure' command (not using java -cp ...). When I try to (ns mynamespace (:require clojure.contrib.X)) I'm told clojure.contrib isn't in my classpath. How can I fix this?

16:33 ibdknox: dnolen: Inlining those would definitely help, but I don't think those operations are the limiting factor in the loops

16:35 renjikken: your life will be much easier if you use leiningen: https://github.com/technomancy/leiningen

16:35 dnolen: ibdknox: what else would be the problem?

16:35 ibdknox: dnolen: I'll try to dig into it and find out :)

16:36 scottj: did rich's strangeloop talk have very many slides?

16:38 cemerick: A fair number. Maybe more than usual, even.

16:40 Raynes: I wish I could pull off a talk with one slide and one bullet point.

16:40 Don't think that'll work out this go around though.

16:41 scottj: https://github.com/strangeloop/2011-slides if anyone's interested (no dnolen or rhickey yet though)

16:42 renjikken: Yeah... ibdknox you've really only introduced a lot more complexity to my problem here.

16:43 theignorati: how do I set POST data with clj-http? :#

16:43 scottj: renjikken: that clojure command is non-standard most likely very few here use it

16:43 renjikken: or have a clue how it works/accepts changes to classpath

16:43 ibdknox: renjikken: heh. Lein makes it very easy to handle your classpath.

16:44 renjikken: how are you running clojure? Just with java -jar?

16:44 renjikken: ibdknox: That's great but that means I have to learn a whole new tool first. It'd be pretty swell if you could actually tell me something I could do _now_ so I can get my homework done _tonight_. :)

16:44 No. As I said in my first message, with just 'clojure'.

16:44 ibdknox: lol

16:44 passive agressive much?

16:44 scottj: ibdknox: it's probably a debian only script

16:44 ibdknox: I'm trying to help you.

16:45 scottj: renjikken: install lein it takes 5 minutes

16:45 renjikken: Yes I believe I've done that.

16:45 Though I'm now forced to look through this Lein to manage my classpath instead. Not any closer to a solution as far as I can see.

16:45 ibdknox: renjikken: project.clj

16:46 renjikken: add clojure.contrib as a dependency.

16:46 renjikken: ibdknox: whatdoesthatevenmean.py

16:46 arohner: kjeldahl: I saw an 8x perf improvement by switching from dbcp to c3p0

16:46 kjeldahl: and the code to set up the DB connections halved

16:46 ibdknox: renjikken: Good luck with your homework then :)

16:46 TimMc: renjikken: Try installing not-acting-like-an-entitled-asshat.deb

16:47 theignorati: .jpg.exe

16:47 icey: renjikken: what timmc said, but you might have to use sudo first… i.e. "sudo not-acting-like-an-entitled-asshat.deb"

16:47 renjikken: I'd be happy to as soon as someone would like to try actually answering my question rather than throwing names of things I don't know at me.

16:47 scottj: renjikken: have you read the readme? https://github.com/technomancy/leiningen

16:48 renjikken: I have looked at it a little, scottj. We've never actually worked with java before (crazy, right?) though, so I'm not familiar with the org.clojure stuff (which is some java convention?).

16:49 ibdknox: renjikken: from a terminal: lein new my-project

16:49 cd my-project

16:49 scottj: not important

16:49 ibdknox: vim project.clj

16:50 scottj: renjikken: or rather, dependencies have 3 main parts, group (who made them), artifact (name of the lib), and version. org.clojure is the group part

16:50 ibdknox: make your dependencies look like this: https://github.com/ibdknox/sudoku-solver/blob/master/project.clj

16:51 lein deps

16:51 you're done

16:54 theignorati: is there a http client lib with proper docs?

16:54 cemerick: Gosh, if only Clojure were *easier*.

16:56 theignorati: found one

16:57 scottj: theignorati: which one?

16:57 theignorati: clj-apache-http

16:57 renjikken: Alright. It seems to have worked. Do I have to install the dependencies every time I make a project, though? Or is that not what it was doing?

16:57 zerokarmaleft: you configure project deps on a project by project basis

16:57 scottj: renjikken: it downloaded them to ~/.m2 it will copy them from there into each new project's dir by default

16:59 renjikken: I see. Alright. Thanks for the help.

17:00 zerokarmaleft: renjikken: https://github.com/technomancy/leiningen/blob/1.x/sample.project.clj <= technomancy went to the effort of commenting the hell out of this

17:00 renjikken: Right on.

17:00 zerokarmaleft: or maybe it was someone else

17:01 anyway, that's super useful

17:01 renjikken: It certainly will be. Thanks.

17:03 zerokarmaleft: i detect an edge of surliness there

17:32 kij: Is there an way to move forms around in vim? pretty sure i used something for emacs back in the days, just cant remember the name :/

17:33 grim_radical: when using defmethod, where in the declaration would one place a docstring?

17:34 scottj: grim_radical: maybe only in defmulti

17:34 cemerick: grim_radical: defmethod doesn't actually intern a new var, so there'd be no place for docs to go

17:35 grim_radical: cemerick: ah, ok

17:35 * cemerick wishes defmethod were add-method! or something

17:35 scottj: kij: it's called paredit in emacs, I think there's a minimal port to vim

17:36 kij: scottj: thanks, ill have a google.

17:36 ibdknox: kij: ya( ca(

17:36 there are text objects for parens :)

17:37 kij: ci( would change everything inside of a paren pair

17:47 kij: this is what i was looking for: https://github.com/vim-scripts/slimv.vim/blob/master/plugin/paredit.vim

17:59 dnolen: ibdknox: hmm, I wonder if limiting the the use of js* to :inline metadata would be enough ...

18:02 ibdknox: dnolen: that sounds reasonable to me

18:37 ozataman: hi all. I'm having some trouble getting emacs play with clojure. c-x c-e says no lisp sub-process; s-c s-z says no such file or directory, lisp. not sure where to go from here...

18:38 I have package, clojure-mode, slime, slime-ritz installed.

18:38 scottj: ozataman: lein project? M-x clojure-jack-in

18:38 ozataman: scottj: it's just a single file I wanted to use for experimenting/learning

18:38 scottj: ozataman: ok not sure anyway if clojure-jack-in works with ritz

18:39 ozataman: so have you started ritz (or swank)?

18:39 ozataman: btw do you know why you're using ritz or did you just install it because it had slime in the name?

18:42 ozataman: btw if you don't need slime/swank you could do C-u M-x inferior-lisp java -cp pathtoclojure.jar clojure.main that would give you C-x C-e

18:46 ozataman: scottj: sorry, was pulled away for a bit. not sure if I have started ritz. the only reason I installed that is because I saw in some post that it is what you need for slime. I'm pretty new to all this, so not sure what the right setup is to get even a simple clojure-emacs setup.

18:46 scottj: ozataman: ritz is sweet but I'd hold off on that till later

18:46 ozataman: I first tried swank, then saw ritz succeeded it as a project, so switched

18:47 scottj: ozataman: best install lein first create a play project then follow https://github.com/technomancy/swank-clojure instructions and use clojure-jack-in

18:50 ozataman: scottj: I tried that as well. still having the problem. I created a new lein project, got in the core.clj inside the project, did the jack-in and c-x c-e is still not working.

18:50 scottj: did jack in bring up a slime repl

18:51 ozataman: no, the minibuffer "starting swank..." message just goes away after a while

18:51 scottj: well you still have slime-ritz installed?

18:52 btw you can try lein swank in term then M-x slime-connect

18:52 ztellman: srid: were you able to get something up and running with the changes suggested on the mailing list?

18:52 ozataman: scottj: I deleted slime-ritz from the elpa folder and restarted emacs

18:52 let me try that

18:52 scottj: ztellman: just read through your slides, thanks for sharing

18:53 ztellman: scottj: I hope they make sense without my color commentary

18:53 ozataman: scottj: slime-connect seems to have worked but I don't see a repl. just some feedback on the minibuffer when I do c-x c-e

18:54 ztellman: according to alex miller, it may be several months before the video is released

18:54 scottj: last time that was the case it showed up on infoq

18:55 ztellman: the psuedocode was just that right, not a real language?

18:56 ztellman: scottj: yeah, just pseudocode

18:56 scottj: ozataman: the repl normally comes up at the slime-connect not when you do C-x C-e, loook for buffer *slime-repl clojure*

18:56 ozataman: scottj: don't have one. is slime-repl something I need to install? package-install gives an error when I try that.

18:57 scottj: also, is slime-clj needed?

18:58 scottj: ozataman: no to slime-clj, not sure on slime-repl that could be why you're not seeing it

18:59 srid: ztellman: i will take a look, but i fixed that problem by not using lein ring (which is not idea) ... now, I can't get the streaming example working. the browser (and curl) is forever "loading" that page

18:59 oh, aleph requires netty, I see

18:59 scottj: ozataman: anyway if you're happy with C-x C-e you don't need the repl :)

19:00 ztellman: srid: you need to start the server using aleph.http/start-http-server

19:00 srid: ztellman: yea, I did that.

19:00 ozataman: scottj: well, repl would be nice :) I'm just trying to get the hang of it all

19:00 srid: ztellman: i can paste my program if you want

19:00 ztellman: yeah, please do

19:00 ozataman: scottj: ahha, slime-repl was the reason. I have a repl now!

19:02 srid: ztellman: just a moment, i'm currently registering for clojure/conj :)

19:02 ztellman: srid: no rush

19:02 ozataman: scottj: thank you

19:10 scottj: on a *swank* buffer, I see "sh: line 1: lein: command not found" after tyring clojure-jack-in. any idea how I can get aroudn this?

19:21 ztellman: srid: I'm going to step out for a bit

19:21 if I copy/paste the example into a command-line repl, it works fine

19:22 using a lein swank repl seems to screw up future calls, though

19:22 so if you're using swank, try replacing the future call with (.start (Thread. #(… ))

19:34 technomancy: (fixed in lein

19:40 srid: technomancy: coming to clojure/conj this year?

19:41 technomancy: srid: fer sher

19:44 srid: this will be my second conference. i broke my leg at the first.

19:46 technomancy: better luck this time

19:51 ozataman: is it normal for slime-repl to crash on a wrong type argument?

19:51 technomancy: can't say that it is, no

19:52 ozataman: it makes emacs freeze for ~45secs and then recovers

19:52 I keep seeing a blinking white square at the middle of the screen

19:52 technomancy: hmm; never heard of that before

19:54 ozataman: very strange; commands are all garbled up now. can't do much unless I restart emacs

19:55 several of these got posted in the *messages* buffer: error in process filter: Wrong type argument: characterp, nil

19:56 technomancy: that's an elisp bug

19:56 ozataman: any several functions got unbound - I can't even list buffers, etc.

19:57 technomancy: wow

19:58 amalloy: ozataman: blinking white square in the middle sounds like the visible bell

19:58 ozataman: whatever I try - like c-x c-b, I keep getting the same error: define-key: Wrong type argument: characterp, nil

19:58 amalloy: I see - I thought I had disabled it; started seeing it again after installing the starter-kit

19:58 technomancy: oh, I thought you said it became unbound

19:59 ozataman: it's almost like the error I caused through slime-repl got stuck

19:59 technomancy: sorry, still new to both emacs and lisp. pardon my lack of proper terminology.. trying to get there :)

20:02 technomancy: the only elisp package required to use M-x clojure-jack-in is clojure-mode

20:02 you can try removing the others; some of them are known to be incompatible (slime-clj) and seeing if you can repro

20:03 ozataman: ok, will try

21:47 choffstein: Anyone know a good clojure or java library that can perform a minimization of a given function?

21:47 So, likely, a math library. Incanter doesn't seem to have what I need

22:36 quotemstr: Can Clojure run as an applet?

22:38 amalloy: quotemstr: it should certainly be possible. but it might need to be an applet with more privileges than the built-in sandbox: for example, it probably needs permission to install a new classloader

22:38 quotemstr: amalloy: Thanks.

22:39 amalloy: and clojurescript is more "hip" for client-side execution of clojure, at the moment

22:40 quotemstr: amalloy: Of course, but if I need to write an applet to use some API anyway, I might as well use Clojure to write it.

22:53 nkoza: why this don't work? (binding [get #(+ %1 %2)] (get 4 5)) ? I see "get" as a Var like anyother

22:54 hiredman: ,(meta #'get)

22:54 clojurebot: {:ns #<Namespace clojure.core>, :name get, :file "clojure/core.clj", :line 1387, :arglists ([map key] [map key not-found]), ...}

22:54 hiredman: ,(:inline-arities (meta #'get))

22:54 clojurebot: #{2 3}

22:55 hiredman: ^- gets inlined by the compiler

22:55 jli: huh, interesting

22:55 hiredman: binding like that also won't work on 1.3

22:55 since binding only works on dynamic vars and dynamic vars are not the default anymore

22:56 nkoza: thanks

22:56 jli: hiredman: oh? is (def ...) in user code no longer dynamic?

22:57 nkoza: btw, in 1.2 I can do (set! *warning-on-reflection* true) but I can't do (def w 3) and a (set! w ..) outside a binding form. How *warning-on-reflection* is different from w?

22:58 amalloy: the repl establishes a top-level thread-local binding for *warn-on-reflection* for you

22:59 you could (binding [w 10] (set! w 100) (...w is 100 until binding ends...))

22:59 but don't do that

23:00 nkoza: amalloy: so doing (set! *warning-on-reflection* ..) outside the repl (and outside a binding form) will not work ?

23:00 amalloy: it might be clojure.main that establishes it, but i'm pretty sure there are contexts where that won't work, yes

23:02 nkoza: ok, thanks

23:05 I read methods implemented inside the defrecord definition are faster than ones implemented with extend, how they differ behind the curtains?

23:18 adam_: hey guys, anyone here using clojure in academia?

23:20 symbole: adam_: Somebody probably is using it. You'd have to be more specific.

23:21 adam_: thanks, i've never used IRC before

23:21 symbole: Welcome!

23:22 adam_: i just wanted to talk about clojure, since everyone I know has no idea what it is

23:23 symbole: You've come to the right place.

23:23 adam_: anyway, i was wondering if anyone knows of any bioinformatics/ computational biology projects that use clojure

23:24 that is, beyond bioClojure and that type of thing

23:41 devth: i have a `let` clause that defines a few vars for me. i need to use this same let clause in a few spots. how do i extract that into a separate function?

23:41 nkoza: use a macro

23:42 devth: nkoza: ah, right. thanks. first day of clojure :)

23:46 dakrone: adam_: there's a group that started not too long ago working on https://github.com/jayunit100/BioClojure

23:48 adam_: thanks dakrone

23:50 quotemstr: Is there any reason the compiler allows (let [foo 42] (foo)) to compile without a peep?

23:50 jli: it's a dynamic language

23:51 quotemstr: jli: Of course, but it's pretty obvious that that construct will never work.

23:51 Ahwell.

23:51 jli: it's a dynamic language :)

23:51 * quotemstr uses Clojure for the first time in anger.

23:52 nkoza: the "sufficient advanced compiler" can detect itthe problem, but that compiler is always a mythical creature :)

23:52 quotemstr: Is there anything like elisp's (format "%S" obj) that'll print out a representation of any kind of object?

23:53 jli: quotemstr: (str whatever-object)

23:54 quotemstr: Awesome! Thanks.

23:54 jli: hm, how do you use clojurebot

23:54 (doc str)

23:54 clojurebot: "([] [x] [x & ys]); With no args, returns the empty string. With one arg x, returns x.toString(). (str nil) returns the empty string. With more than one arg, returns the concatenation of the str values of the args."

23:54 srid: quotemstr: yet another elisper learning clojure?

23:55 symbole: quotemstr: foo can refer to a Var or a function. It's not clear that it shouldn't be allowed.

23:55 quotemstr: srid: And CLer. :-)

23:55 srid: The FORMAT incantation just wasn't coming to mind.

23:55 srid: quotemstr: the "quick ref" at clojuredocs.org is pretty handy

23:56 quotemstr: (~S maybe?)

23:56 srid: if you look at the 'format' docs at clojuredocs.org it links to the java docs with full format spec

23:56 jli: there's also clojure.core/format

23:56 (doc format)

23:56 clojurebot: "([fmt & args]); Formats a string using java.lang.String.format, see java.util.Formatter for format string syntax"

23:57 srid: yes, you need the java docs for format spec, which is linked from the unofficial docs site. that is what i like about it; anybody can edit docs (well, more like adding links and examples)

Logging service provided by n01se.net