#clojure logs

2011-09-21

04:03Fossii found a bug in the ring cookie parsing (it's simply broken with large cookies). anybody know where i could post the testcase/report?
05:08thorwilFossi: since the github page has no Issues, i guess http://groups.google.com/group/ring-clojure
05:15Fossithorwil: thanks, will post
05:24fliebelDoesn't cake understand :source-path?
05:33michaelr525hello
05:51scottjfliebel: there's a cake channel, #cake.clj I think
06:31teromAnybody 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.)
06:50clgvterom: 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.
07:51lnostdalsome 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?
08:05joegallo(eval-after-load 'clojure-mode '(add-hook 'clojure-mode-hook (lambda () (put-clojure-indent 'your-macro-here 'defun))))
08:05joegallomore or less
08:06joegallothat'll handle the indenting, but not highlighting like a keyword (which is nice for macros)
08:07joegallofor the highlighting, you'd want a similar callback, or just use the same one, and this inside:
08:08joegallo(font-lock-add-keywords 'clojure-mode '(("(\\(your-fn-here\\)" (1 font-lock-keyword-face))))
08:08joegalloagain, more or less
08:11Blktgood afternoon everyone
08:12mdeboard``morning
08:13Blktcould anyone explain me whythis code always returns nil?
08:13Blkt(loop [k '(1 4 7 10 13) acc '()]
08:13Blkt (cond (< 2 (count k)) acc
08:13Blkt :else (recur (drop 2 k) (cons (take 2 k) acc))))
08:13opqdonutsince < should be > ?
08:14mdeboard,(acc '())
08:14clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: acc in this context, compiling:(NO_SOURCE_PATH:0)>
08:14clgvand it returns '() and not nil ;)
08:14mdeboardoh
08:14BlktI suppose that means that I'm a bit tired...
08:14Blktshould eat something
08:14opqdonut,'()
08:14clojurebot()
08:14mdeboardSo, recur just has to be in the tail position for the loop, not the whole function?
08:15opqdonutmdeboard: recur needs to be in tail position wrt. the recur point
08:15mdeboardopqdonut: Got it
08:15opqdonutwhich is the innermost loop/function/thing
08:15mdeboardthanks
08:15opqdonutthink of loop just as defining a recursive helper function and calling it right away
08:16Blktthanks for the help
08:16mdeboardI don't why I was thinking it had to be in absolute tail position, guess that means taht I'm a bit tired...
08:19clgvmdeboard: in the above example it also is in "absolute" tail position provided I interpret that term right
08:19mdeboardyeah absolute to the outer context
08:19mdeboardouter scope*
08:20lnostdaljoegallo, thank you!
08:20clgvmdeboard: in fact to the whole expression
08:21mdeboardclgv: How so? `acc` is in the tail position
08:21clgvmdeboard: there are two tailposition due to the branching via cond.
08:22mdeboardclgv: Maybe I misunderstand what tail position is then...I'll googe.
08:23manuttertail position means that the function does not do any further processing on the results of the call to recur
08:23clgvmdeboard: one keypoint is that you are not allowed to modify the result of the recursive call.
08:23mdeboardmanutter: Ok, I think that's clear enough. I was making it more complicated
08:25manutterI suppose I should say "the loop or function does not do any further processing"
08:25manutterbut that's the main point
08:56khaliGis there a good reason to seperate model and view (swing) in clojure?
08:58manutterprobably.
08:58manutter:)
08:58manutterIs there something you'd rather do instead of keeping them separate?
09:00khaliGmanutter, yea, not :) i'm just getting fed up abusing closures
09:01manutterI've always heard of MVC in connection with OOP, but I can't see any reason why it would be tied to OOP specifically
09:02manutterare you sure it's "abuse" and not "idiom"?
09:04khaliGmanutter, honestly, I don't see the difference between the two :/
09:04manutterHeh
09:04manutterIf it's your own personal project, might be interesting to experiment with the alternatives
09:05manutterif MVC is a valid design principle, then you'll start having problems with changes to your model forcing cascading changes to your views
09:05manutterbut I have to say in my experience a change in the model tends to have that effect anyway
09:08khaliGi might experiment - can't be any worse than what i've got so far :P
09:22pyninjaQuestion 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.
09:24pyninjacould it be an SSL issue?
09:24pyninjadakrone: hey are you around?
09:26manutterpyninja: what results do you get from clj-http?
09:26pyninjamanutter: 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.
09:27manutterwhat's the error?
09:27pyninjamanutter: i mean it's a paypal error - "timeout processing request". not very helpful...
09:27manutter(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)
09:28pyninjaheh
09:28pyninjai'm suspecting it's an SSL thing probably, since Paypal's PHP sample code seems to be turning off SSL verification.
09:29pyninjaI wonder if there's a way to disable SSL verification in clj-http...
09:29manutteryeah, sounds plausible
09:35Blkthow do I create a Double[] from a sequence?
09:35BlktI need to feed it to class method
09:40clgvBlkt:## (doc double-array)
09:40clgv&(doc double-array)
09:40clgv,(doc double-array)
09:40clojurebot"([size-or-seq] [size init-val-or-seq]); Creates an array of doubles"
09:41joly,(double-array [1 2 3])
09:41clojurebot#<double[] [D@1fd9ce4>
09:41clgv,(seq (double-array [1 2 3]))
09:41clojurebot(1.0 2.0 3.0)
09:42Blktthanks a lot clojurebot
09:42Blkter...
09:43Blktthanks a lot clgv
09:45clgvBlkt: there are more like this for e.g. int
09:45pyninjamanutter: so yeah it looks like actually ssl is not the issue. i enabled ssl verification in their php sample code, and it still works.
09:46Blktclgv: I just noticed it by M-. double-array
09:48manutterpyninja: I'll have to play with it tonight when I'm at my main clojure pc
09:49clgvmanutter: "clojure mainframe" ? ;)
09:49manutterheh, just about :)
09:49choffsteinDoes 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:03khaliGchoffstein, yes, do you have an example pasted somewhere?
10:04choffsteinNothing 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:05choffstein(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:06dbushenkowhich is the most correct way to start slime session: slime-connect or clojure-jack-in?
10:06choffsteinErr, (formatter "E MMM d HH:mm:ss zzz yyyy")
10:06manutterdbushenko: depends if you've done "lein swank" at the command line
10:07manutterclojure-jack-in starts swank for you
10:07dbushenkomanutter, I don't use emacs-starter-kit, so probably my clojure-mode differs a bit
10:07dbushenkobut when I try to connect with slime-connect
10:08dbushenkoemacs doesn't open the repl
10:08dbushenkoclojure-jack-in opens the repl and works fine
10:08dbushenkowhat's wrong with slime-connect?
10:09manutterdbushenko: I don't use emacs starter kit either, just clojure mode and swank-clojure
10:09manutterare you starting swank with lein swank or something equivalent?
10:09scottjdbushenko: did you start swank with lein swank?
10:09dbushenkomanutter: what package manager and clojure-mode version do you use?
10:09dbushenkoscottj, sure
10:10manutterI'm not sure, but the latest version of each, as far as I know
10:10dbushenkomanutter, yep, but there are different package managers for emacs, as I know
10:10dbushenkowhich one do you use?
10:10manutterdo you have a *swank* buffer in emacs? Might be some interesting info there if so
10:10scottjdbushenko: look in Messages or *slime events* etc for some error message
10:11dbushenkomanutter, no, *swank* doesn't open
10:12dbushenkoscottj, Connecting to Swank on port 4005.. [2 times]
10:12dbushenkoerror in process filter: slime-intern-indentation-spec: Wrong type argument: listp, 1
10:12dbushenkoerror in process filter: Wrong type argument: listp, 1
10:12dbushenkoseems like this is all of the errors
10:13manutterhmm, yeah, sounds like some kind of version conflict between different libraries.
10:14dbushenkoso which versions do you use?
10:15manutterI basically wiped out my old stuff and followed the instructions at https://github.com/technomancy/swank-clojure
10:15dbushenkotechnomancy, hi, I do exactly as described in https://github.com/technomancy/swank-clojure
10:15dbushenkobut only clojure-jack-in runs, slime-connect doesn't open the repl
10:16dbushenkois that ok or I've done something wrong?
10:16dbushenkomanutter, OMG, I did exactly as described there....
10:16dbushenkowhat could that be?
10:17manutterhmm, I'm running out of clues, my only guess is maybe some old libs still hanging around inside .emacs or .emacs.d?
10:18scottjM-: (slime-changelog-date)
10:19scottjactually not sure if that works with elpa version of slime
10:19dbushenkook, thank you guys, I'll try emacs 24
10:19dbushenkobye!
10:23khaliGchoffstein, 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:23choffsteinkhaliG: 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:25khaliGchoffstein, yep you'd have to preprocess the string before hand, agreed it's not as nice
10:27choffsteinkhaliG: i'll give it a whirl. might not be sexy, but it might get the job done
10:28khaliGchoffstein, sounds good :)
10:29bsod1hi, 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:29clojurebotclojure bot is not immune to ,(iterate inc 0)
10:32terombsod1: make sure you're using the correct update site (http://ccw.cgrand.net/updatesite)
10:34teromWiki page for installation has some older update site which is not in use, probably
10:34bsod1terom: great, thanks
10:48clgvbsod1: yeah 0.3.0 is latest CCW version
10:48bsod1clgv: is it compatible with eclipse indigo? repl is not working. also clojure perspective is not added.
10:49clgvbsod1: yes I have CCW 0.3.0 workin on 3 machines with eclipse indigo
10:49clgvno special magic was need to get it running
10:50bsod1clgv: ok I'm installing again
10:50clgvif you have any old version, get rid of it before installing the new one
10:50bsod1no I didn't have any old versions
10:53scottjcan protocol methods have vargs?
10:53choffsteinAnyone know a way to drop the nth item in a sequence?
10:53choffsteinI suppose I could index the items then filter … but that just seems ugly
10:54clgvscottj: no they cant
10:54pdk(doc drop-nth)
10:54clojurebotIt's greek to me.
10:54clgvbut you dont get an error in clojure 1.2 and the '& is interpreted as param name
10:55scottjclgv: ty
10:57choffsteinalright. gotta run. have a good one everyone
10:59bsod1clgv: I've uninstalled and installed again but still same, can't run REPL and clojure perpective isn't added
11:00clgvbsod1: so what did you do after installing? did you create a clojure project?
11:00bsod1yes
11:00manutterbsod1: other plugins installed?
11:00bsod1manutter: no, just standart eclipse indigo
11:01bsod1manutter: erm, and viPlugin
11:01clgvbsod1: there is no clojure perspective yet, but there are several views
11:01clgvbsod1: you'll get a repl by running a clojure file of your project
11:02bsod1clgv: wait, I opened REPL view and can run commands now
11:02bsod1clgv: 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:03bsod1clgv: also, is there a way to disable rainbow parens?
11:04clgvbsod1: why would you want to disable coloring of parens?
11:05clgvwhats the error message? the ctrl+alt+s works well here
11:05bsod1clgv: looks bad, it already highlights it's pair when I move cursor on to a paren
11:06bsod1clgv: hmm, looks like after opening REPL view, ctrl+alt+s works
11:07bsod1clgv: do you know any must-know hotkeys for counterclockwise? like `show documentation`?
11:07clgvctrl+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:09TimMcC-M-n, you mean
11:09kzarIf 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:10clgvbsod1: the outline view is also nice
11:10bsod1clgv: can you look at my REPL view? something wrong, it's not working http://ompldr.org/vYWduNg/counterclockwise.png
11:10clgvTimMc: no I do not
11:11TimMcYou don't?
11:11clgvbsod1: seems you killed the nrepl server. the view still stays alive
11:12clgvbsod1: you kill the nrepl server via the "terminate" button in the console view, but that doesnt close the repl view
11:14clgvbsod1: solution => just close the old view and restart a repl
11:17kzarOh it looks like this might do what I want. https://github.com/marktriggs/xml-picker-seq
11:18simardI 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:19clgvsimard: examples! *got a knot in my head reading the description*
11:23simardok: (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:23simardand that draw should yield (f2 {:a 2}) (f2 {:a 3})
11:24bsod1clgv: I've tried reopening REPL view but didn't work, I restarted eclipse and still the same, something wrong with this REPL view
11:27clgvbsod1: no. you have to restart a repl! not the view.
11:28jolysimard: maybe something like (defn draw [xs] (doseq [x xs] (if (map? x) (f2 x) (apply draw x))))
11:28clgvbsod1: 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:30bsod1clgv: do you mean this? http://ompldr.org/vYWducA
11:30manuttereclipse is too complicated, I'm sticking with something easy like emacs.
11:30clgvmanutter: roflmao!
11:30Bronsalol manutter
11:31manuttersry, couldn't resist :)
11:32clgvbsod1: 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:32simardjoly: hum that doesn't actually build a tree out of the return values of draw does it ?
11:32simardit's just for side effecs
11:32simardeffects*
11:33jolycan change doseq to for if you want the results back
11:33bsod1clgv: I have nothing in console view :)
11:33jolysimard: ^
11:33simardoh :)
11:33simardthank you
11:33jolysure thing :)
11:34bsod1clgv: do you want a screenshot :)
11:34clgvbsod1: ah hm. your source folder is displaying an error. you should have a look at that
11:34bsod1clgv: really? it's a java project(actually java standart api source code from oracle JDK)
11:34clgvbsod1: what? didnt you create a clojure project?
11:35bsod1clgv: clojure_test project is clojure project, and test1.clj is in it
11:35clgvbsod1: ah k that is another project :P
11:36bsod1clgv: :) 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:37bsod1clgv: thanks
11:37clgvbsod1: yeah I guess there is no backwards compatibility between 0.0.64 and 0.3.0 ;)
11:42simardshouldn't that produce a multiline string with numbers from 1 to 10 ? (with-out-str (map println (range 1 10)))
11:42clgv,(with-out-str (map println (range 1 10)))
11:42clojurebot""
11:43simard,(with-out-str (println 10))
11:43clojurebot"10\n"
11:43clgvsimard: ah lol. the lazy map gets evaluated outside the with-out-str
11:43clgv,(with-out-str (doall (map println (range 1 10))))
11:43clojurebot"1\n2\n3\n4\n5\n6\n7\n8\n9\n"
11:44simardclgv: even when I enclose it with a (spit ...), it doesn't work
11:44clgvsimard: 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:44simardoh
11:45simardmakes sense
11:45simardtricky :)
11:45clgv,(doall (with-out-str (map println (range 1 10))))
11:45clojurebot""
11:45clgvsee above ^^
11:45clgvsimard: you can use doseq for side effects
11:46clgv,(with-out-str (doseq [i (range 1 10)] (println i)))
11:46clojurebot"1\n2\n3\n4\n5\n6\n7\n8\n9\n"
11:49simardis there a function that combines (doseq) and (flatten) ?
11:49simardlike... dotree
11:50clgvsimard: not that I know of. just put the flatten call where range was in the example
11:50clgvor do you need traversing in a certain order?
11:51simardclgv: linear order, so flatten will do
11:51kzarI'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:52clgvkzar: [org.clojure/clojure-contrib "1.2.0"]
11:52clgvminus instead of dot
11:52kzarah balls, thanks clgv
11:53hugodanyone know of a way to get the current test var within an :each fixture in clojure.test?
12:11Blktcya tomorrow everyone
12:13jliI 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:14jlibasically: (zipmap (line-seq (clojure.java.io/reader file)) (map inc (range)))
12:19clgvjli: what will you do with the index?
12:19kzarHow do you have `lein deps` grab Java libraries that aren't hosted on Clojars?
12:19kzarI wanted to use nu.xom.Document
12:20clgvkzar: you can specify repositories, see the example on leiningens github page
12:22joegalloi 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:23joegallobut i could be wrong, of course
12:23clgvjoegallo: might depend on the leiningen version.
12:24joegallogood point
12:24clgvbut I think I remember it being on the list
12:25clgvI got swingx via mavencentrel
12:25joegalloseems to work as i thought here with leiningen 1.6.1
12:28clgvIhave 1.6.1.1
12:34arohnerrepo support was added to lein a long time ago, like 1.3 or 1.4, you should have no problems with that
12:34arohnerkzar: make sure your dependency is written correctly, that's where most problems occur
12:37kzararohner: 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:38joegallohttp://mvnrepository.com/
12:38joegalloi 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:57zippy314in clojurescript, whats the right way to convert a string to an integer?
12:58malkomalkohey 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:02hugod:reload-all
13:05malkomalkowonderful!
13:14dnolenzippy314: js/parseInt, Google Closure probably has something as well.
13:14zippy314dnolen: thanks! I just figured out the js namespace. Not very well documented!
13:22simardI 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:23simardie.: it seems vars won't do because I don't want lexical scope binding but permanent change of the value stored in *point*
13:23drewran atom may suffice
13:23drewrno earmuffs
13:26hiredmanor even better, pass in the function you need to where you need it
13:27hiredman(binding [*function-to-map* inc] (map (range 10))) ;; kind of silly
13:27sridi 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:27hiredmanC-c C-c
13:27sridalternatively, is there a way to launch the server and return immediately.
13:27hiredmanyes
13:27hiredmanread the docs for the function
13:27sridthat works, thanks
13:30srid:join? and defonce will work, http://stackoverflow.com/questions/2706044/
13:34hiredmansrid: 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:35hiredmanyou should have a function that starts the server, and just call that function at the repl when you want to start a server
13:36sridhiredman: i defonce in repl. but now i'm inclining to use ring's "ring server"
13:36hiredmanfrom lein ring?
13:36sridyes
13:36hiredmanit's a nice plugin
13:36sridit auto restarts on file change.
13:39sridhere'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:39srid; protocol: #'lamina.core.channel/ChannelProtocol found for class: nil) ... any idea why?
13:40hiredmanI imagine protocols don't play nice with lein-rings reloading
13:51sridhiredman: seems so. not using lein-ring fixes the issue
13:51sridhiredman: is there a workaround, so I can still use lein-ring? (i haven't read about protocols and records yet)
13:53hiredmannot really
13:58sridthe streaming requests example from aleph doesn't work at all.
13:59sridmaybe i should stop relying on beta software to get something up and running today
14:21zippy314here'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:23manutterzippy314: no, that's plain old js closure
14:23manutteryou need a function that takes hid as an argument, and returns the anonymous function you've got there
14:28zippy314manutter: 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:29manutteryou might not always want it to :)
14:32manutterthe compiler is behaving correctly, you just have to understand function scope and how to use it
14:32manuttersince hid was a var outside the scope of the anonymous function, all the anonymous functions you created referred to the same "hid"
14:33manutterby 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:34pandeiroShould ClojureScript always follow the prototype chain when dealing with objects with inherited properties and methods?
14:35pandeiroI want to call preventDefault on an event but it's saying the method doesn't exist
15:20carllercheis there anyway to dispatch a protocol on a byte array?
15:21kjeldahlAnybody have any pointers to using jdbc with a persistent connection, i.e. not using with-connection, but rather some variant of get-connection?
15:25kjeldahlNever mind; with-connection uses get-connection, and I guess a "top-level" with-connection neatly solves it.
15:25dnolencarllerche: yes, http://dosync.posterous.com/51626638
15:32carllerchednolen: huh that's interesting
15:32carllercheyou can extend types at runtime? i did not know that
15:37ibdknoxdnolen: I have bad news on the cljs perf front
15:40mattmitchellanyone here use midje?
15:41fdaoudmattmitchell: have took it for a spin but that's it
15:42khaliGso 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:42mattmitchellfdaoud: what'd you think?
15:43fdaoudmattmitchell: looks nice, will go back to it but for now clojure.test satisfies my needs
15:43mattmitchellfdaoud: cool thanks
15:49dnolenibdknox: what in particular? I've done a few tests myself.
15:49ibdknoxdnolen: iterating over anything is incredibly slow
15:49ibdknoxdnolen: as in 3-4 orders of magnitude slower than native JS
15:50fdaoudmattmitchell: have you tried it?
15:51dnolenibdknox: 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:51mattmitchellfdaoud: 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:51ibdknoxdnolen: matters if you want to do any canvas rendering
15:51dnolenibdknox: that said I think there's a place for amap, areduce, etc. in ClojureScript which compiles down to more efficient operations.
15:52fdaoudmattmitchell: interesting. do you do mocking with it? that would be my primary interest.
15:52dnolenibdknox: could that be solved for your usecase w/ amap/reduce ?
15:52the-kennyAren't closures supported in ClojureScript? I see the following behavior in repljs: https://gist.github.com/1233113
15:52mattmitchellfdaoud: we do yes, works pretty well actually
15:53ibdknoxdnolen: an efficient doseq would cover everything for me
15:53ibdknoxdnolen: the one other place it would be nice amap would be perfect
15:53fdaoudmattmitchell: great, thanks
15:53dnolenthe-kenny: you're just seeing a oddity of REPL output, that works as advertised.
15:54kjeldahlUsing the jdbc with-connection (which closes connection after executing) seems terribly inefficient. Any better methods, or hints about why my assumption is wrong?
15:54the-kennydnolen: Ah, okay :) Thanks
15:54fdaoudkjeldahl: use a connection pool perhaps?
15:56joegalloyeah, seriously, get c3p0 or something behind it and you'll be rockin'
15:57kjeldahlfdaoud: 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:58kjeldahlEasier than I though I guess: https://gist.github.com/470904
15:59fdaoudkjeldahl: like joegallo I'd recommend c3p0 http://www.mchange.com/projects/c3p0/index.html
15:59dnolenibdknox: looking at the implementation of ISeq for arrays. Have you benched loop/recur ?
15:59ibdknoxdnolen: not yet, does it look like it might be more efficient?
16:03dnolenibdknox: yes it looks more efficient, one things that's missing for ClojureScript to be really fast for Canvas like stuff is inlining.
16:04kjeldahlfdaoud/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:04dnolenworth bringing up on the ML to see if we can move forward on that, especially since you could benefit from it now.
16:05ibdknoxdnolen: yeah
16:06ibdknoxdnolen: I'll throw together some stuff on my findings.
16:07dnolenibdknox: that would be awesome.
16:09dnolenibdknox: actually doseq expands to loop/recur so I think you're paying for the indirection of function calls when you really want inlining.
16:10ibdknoxdnolen: 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:10ibdknoxall done with apply, which I believe slows it down even more
16:11dnolenibdknox: hmm I'm not so sure about the apply part.
16:11ibdknoxdnolen: 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:11ibdknoxdnolen: in cljs it was around 3.5-4s
16:12dnolenibdknox: 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:12dnolenyou can't even write keys in localStorage faster than 5000 kv pairs / sec :P
16:12ibdknoxlol
16:13ibdknoxwell, 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:19choffsteinAnyone want to test a lein plugin I wrote? :D https://github.com/newfoundresearch/lein-clj-doc-test
16:19dnolenibdknox: 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:21ibdknoxdnolen: 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:21dnolenibdknox: nah, we just need to find out how disdained js* really is.
16:21ibdknoxlol
16:22dnolenibdknox: if it is disdained then something else is needed that accomplishes what it does.
16:23Raynescemerick: I didn't know you were doing another fundraiser! Cool stuff.
16:23ibdknoxdnolen: So your thought is for certain constructs (loops in this cases), we explicitly write the JS it should output?
16:23RaynesI'm surprised I missed all the tweets about it.
16:24dnolenibdknox: no doseq does the correct thing.
16:24dnolenwhat's wrong is that artithmetic primitives are fn calls and not inlined into JS +, -, /, *, <=, etc.
16:26cemerickRaynes: Yup; seemed like something worth repeating, as much as that's possible. :-)
16:27cemerickputting it out there during the conf ended up not being a fantastic idea.
16:27cemerickThere was only one way to see what would happen, tho.
16:30dnolenspeaking of which please all, retweet this - https://twitter.com/swannodette/status/116610530575269888
16:30dnolencemerick: ^
16:31cemerickdnolen: thanks :-)
16:33renjikkenI 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:33ibdknoxdnolen: Inlining those would definitely help, but I don't think those operations are the limiting factor in the loops
16:35ibdknoxrenjikken: your life will be much easier if you use leiningen: https://github.com/technomancy/leiningen
16:35dnolenibdknox: what else would be the problem?
16:35ibdknoxdnolen: I'll try to dig into it and find out :)
16:36scottjdid rich's strangeloop talk have very many slides?
16:38cemerickA fair number. Maybe more than usual, even.
16:40RaynesI wish I could pull off a talk with one slide and one bullet point.
16:40RaynesDon't think that'll work out this go around though.
16:41scottjhttps://github.com/strangeloop/2011-slides if anyone's interested (no dnolen or rhickey yet though)
16:42renjikkenYeah... ibdknox you've really only introduced a lot more complexity to my problem here.
16:43theignoratihow do I set POST data with clj-http? :#
16:43scottjrenjikken: that clojure command is non-standard most likely very few here use it
16:43scottjrenjikken: or have a clue how it works/accepts changes to classpath
16:43ibdknoxrenjikken: heh. Lein makes it very easy to handle your classpath.
16:44ibdknoxrenjikken: how are you running clojure? Just with java -jar?
16:44renjikkenibdknox: 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:44renjikkenNo. As I said in my first message, with just 'clojure'.
16:44ibdknoxlol
16:44ibdknoxpassive agressive much?
16:44scottjibdknox: it's probably a debian only script
16:44ibdknoxI'm trying to help you.
16:45scottjrenjikken: install lein it takes 5 minutes
16:45renjikkenYes I believe I've done that.
16:45renjikkenThough 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:45ibdknoxrenjikken: project.clj
16:46ibdknoxrenjikken: add clojure.contrib as a dependency.
16:46renjikkenibdknox: whatdoesthatevenmean.py
16:46arohnerkjeldahl: I saw an 8x perf improvement by switching from dbcp to c3p0
16:46arohnerkjeldahl: and the code to set up the DB connections halved
16:46ibdknoxrenjikken: Good luck with your homework then :)
16:46TimMcrenjikken: Try installing not-acting-like-an-entitled-asshat.deb
16:47theignorati.jpg.exe
16:47iceyrenjikken: what timmc said, but you might have to use sudo first… i.e. "sudo not-acting-like-an-entitled-asshat.deb"
16:47renjikkenI'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:47scottjrenjikken: have you read the readme? https://github.com/technomancy/leiningen
16:48renjikkenI 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:49ibdknoxrenjikken: from a terminal: lein new my-project
16:49ibdknoxcd my-project
16:49scottjnot important
16:49ibdknoxvim project.clj
16:50scottjrenjikken: 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:50ibdknoxmake your dependencies look like this: https://github.com/ibdknox/sudoku-solver/blob/master/project.clj
16:51ibdknoxlein deps
16:51ibdknoxyou're done
16:54theignoratiis there a http client lib with proper docs?
16:54cemerickGosh, if only Clojure were *easier*.
16:56theignoratifound one
16:57scottjtheignorati: which one?
16:57theignoraticlj-apache-http
16:57renjikkenAlright. 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:57zerokarmaleftyou configure project deps on a project by project basis
16:57scottjrenjikken: it downloaded them to ~/.m2 it will copy them from there into each new project's dir by default
16:59renjikkenI see. Alright. Thanks for the help.
17:00zerokarmaleftrenjikken: https://github.com/technomancy/leiningen/blob/1.x/sample.project.clj <= technomancy went to the effort of commenting the hell out of this
17:00renjikkenRight on.
17:00zerokarmaleftor maybe it was someone else
17:01zerokarmaleftanyway, that's super useful
17:01renjikkenIt certainly will be. Thanks.
17:03zerokarmalefti detect an edge of surliness there
17:32kijIs 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:33grim_radicalwhen using defmethod, where in the declaration would one place a docstring?
17:34scottjgrim_radical: maybe only in defmulti
17:34cemerickgrim_radical: defmethod doesn't actually intern a new var, so there'd be no place for docs to go
17:35grim_radicalcemerick: ah, ok
17:35scottjkij: it's called paredit in emacs, I think there's a minimal port to vim
17:36kijscottj: thanks, ill have a google.
17:36ibdknoxkij: ya( ca(
17:36ibdknoxthere are text objects for parens :)
17:37ibdknoxkij: ci( would change everything inside of a paren pair
17:47kijthis is what i was looking for: https://github.com/vim-scripts/slimv.vim/blob/master/plugin/paredit.vim
17:59dnolenibdknox: hmm, I wonder if limiting the the use of js* to :inline metadata would be enough ...
18:02ibdknoxdnolen: that sounds reasonable to me
18:37ozatamanhi 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:38ozatamanI have package, clojure-mode, slime, slime-ritz installed.
18:38scottjozataman: lein project? M-x clojure-jack-in
18:38ozatamanscottj: it's just a single file I wanted to use for experimenting/learning
18:38scottjozataman: ok not sure anyway if clojure-jack-in works with ritz
18:39scottjozataman: so have you started ritz (or swank)?
18:39scottjozataman: btw do you know why you're using ritz or did you just install it because it had slime in the name?
18:42scottjozataman: 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:46ozatamanscottj: 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:46scottjozataman: ritz is sweet but I'd hold off on that till later
18:46ozatamanI first tried swank, then saw ritz succeeded it as a project, so switched
18:47scottjozataman: best install lein first create a play project then follow https://github.com/technomancy/swank-clojure instructions and use clojure-jack-in
18:50ozatamanscottj: 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:50scottjdid jack in bring up a slime repl
18:51ozatamanno, the minibuffer "starting swank..." message just goes away after a while
18:51scottjwell you still have slime-ritz installed?
18:52scottjbtw you can try lein swank in term then M-x slime-connect
18:52ztellmansrid: were you able to get something up and running with the changes suggested on the mailing list?
18:52ozatamanscottj: I deleted slime-ritz from the elpa folder and restarted emacs
18:52ozatamanlet me try that
18:52scottjztellman: just read through your slides, thanks for sharing
18:53ztellmanscottj: I hope they make sense without my color commentary
18:53ozatamanscottj: 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:54ztellmanaccording to alex miller, it may be several months before the video is released
18:54scottjlast time that was the case it showed up on infoq
18:55scottjztellman: the psuedocode was just that right, not a real language?
18:56ztellmanscottj: yeah, just pseudocode
18:56scottjozataman: the repl normally comes up at the slime-connect not when you do C-x C-e, loook for buffer *slime-repl clojure*
18:56ozatamanscottj: don't have one. is slime-repl something I need to install? package-install gives an error when I try that.
18:57ozatamanscottj: also, is slime-clj needed?
18:58scottjozataman: no to slime-clj, not sure on slime-repl that could be why you're not seeing it
18:59sridztellman: 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:59sridoh, aleph requires netty, I see
18:59scottjozataman: anyway if you're happy with C-x C-e you don't need the repl :)
19:00ztellmansrid: you need to start the server using aleph.http/start-http-server
19:00sridztellman: yea, I did that.
19:00ozatamanscottj: well, repl would be nice :) I'm just trying to get the hang of it all
19:00sridztellman: i can paste my program if you want
19:00ztellmanyeah, please do
19:00ozatamanscottj: ahha, slime-repl was the reason. I have a repl now!
19:02sridztellman: just a moment, i'm currently registering for clojure/conj :)
19:02ztellmansrid: no rush
19:02ozatamanscottj: thank you
19:10ozatamanscottj: 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:21ztellmansrid: I'm going to step out for a bit
19:21ztellmanif I copy/paste the example into a command-line repl, it works fine
19:22ztellmanusing a lein swank repl seems to screw up future calls, though
19:22ztellmanso if you're using swank, try replacing the future call with (.start (Thread. #(… ))
19:34technomancy(fixed in lein 1.6.1.1)
19:40sridtechnomancy: coming to clojure/conj this year?
19:41technomancysrid: fer sher
19:44sridthis will be my second conference. i broke my leg at the first.
19:46technomancybetter luck this time
19:51ozatamanis it normal for slime-repl to crash on a wrong type argument?
19:51technomancycan't say that it is, no
19:52ozatamanit makes emacs freeze for ~45secs and then recovers
19:52ozatamanI keep seeing a blinking white square at the middle of the screen
19:52technomancyhmm; never heard of that before
19:54ozatamanvery strange; commands are all garbled up now. can't do much unless I restart emacs
19:55ozatamanseveral of these got posted in the *messages* buffer: error in process filter: Wrong type argument: characterp, nil
19:56technomancythat's an elisp bug
19:56ozatamanany several functions got unbound - I can't even list buffers, etc.
19:57technomancywow
19:58amalloyozataman: blinking white square in the middle sounds like the visible bell
19:58ozatamanwhatever I try - like c-x c-b, I keep getting the same error: define-key: Wrong type argument: characterp, nil
19:58ozatamanamalloy: I see - I thought I had disabled it; started seeing it again after installing the starter-kit
19:58technomancyoh, I thought you said it became unbound
19:59ozatamanit's almost like the error I caused through slime-repl got stuck
19:59ozatamantechnomancy: sorry, still new to both emacs and lisp. pardon my lack of proper terminology.. trying to get there :)
20:02technomancythe only elisp package required to use M-x clojure-jack-in is clojure-mode
20:02technomancyyou can try removing the others; some of them are known to be incompatible (slime-clj) and seeing if you can repro
20:03ozatamanok, will try
21:47choffsteinAnyone know a good clojure or java library that can perform a minimization of a given function?
21:47choffsteinSo, likely, a math library. Incanter doesn't seem to have what I need
22:36quotemstrCan Clojure run as an applet?
22:38amalloyquotemstr: 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:38quotemstramalloy: Thanks.
22:39amalloyand clojurescript is more "hip" for client-side execution of clojure, at the moment
22:40quotemstramalloy: 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:53nkozawhy this don't work? (binding [get #(+ %1 %2)] (get 4 5)) ? I see "get" as a Var like anyother
22:54hiredman,(meta #'get)
22:54clojurebot{:ns #<Namespace clojure.core>, :name get, :file "clojure/core.clj", :line 1387, :arglists ([map key] [map key not-found]), ...}
22:54hiredman,(:inline-arities (meta #'get))
22:54clojurebot#{2 3}
22:55hiredman^- gets inlined by the compiler
22:55jlihuh, interesting
22:55hiredmanbinding like that also won't work on 1.3
22:55hiredmansince binding only works on dynamic vars and dynamic vars are not the default anymore
22:56nkozathanks
22:56jlihiredman: oh? is (def ...) in user code no longer dynamic?
22:57nkozabtw, 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:58amalloythe repl establishes a top-level thread-local binding for *warn-on-reflection* for you
22:59amalloyyou could (binding [w 10] (set! w 100) (...w is 100 until binding ends...))
22:59amalloybut don't do that
23:00nkozaamalloy: so doing (set! *warning-on-reflection* ..) outside the repl (and outside a binding form) will not work ?
23:00amalloyit might be clojure.main that establishes it, but i'm pretty sure there are contexts where that won't work, yes
23:02nkozaok, thanks
23:05nkozaI read methods implemented inside the defrecord definition are faster than ones implemented with extend, how they differ behind the curtains?
23:18adam_hey guys, anyone here using clojure in academia?
23:20symboleadam_: Somebody probably is using it. You'd have to be more specific.
23:21adam_thanks, i've never used IRC before
23:21symboleWelcome!
23:22adam_i just wanted to talk about clojure, since everyone I know has no idea what it is
23:23symboleYou've come to the right place.
23:23adam_anyway, i was wondering if anyone knows of any bioinformatics/ computational biology projects that use clojure
23:24adam_that is, beyond bioClojure and that type of thing
23:41devthi 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:41nkozause a macro
23:42devthnkoza: ah, right. thanks. first day of clojure :)
23:46dakroneadam_: there's a group that started not too long ago working on https://github.com/jayunit100/BioClojure
23:48adam_thanks dakrone
23:50quotemstrIs there any reason the compiler allows (let [foo 42] (foo)) to compile without a peep?
23:50jliit's a dynamic language
23:51quotemstrjli: Of course, but it's pretty obvious that that construct will never work.
23:51quotemstrAhwell.
23:51jliit's a dynamic language :)
23:52nkozathe "sufficient advanced compiler" can detect itthe problem, but that compiler is always a mythical creature :)
23:52quotemstrIs there anything like elisp's (format "%S" obj) that'll print out a representation of any kind of object?
23:53jliquotemstr: (str whatever-object)
23:54quotemstrAwesome! Thanks.
23:54jlihm, how do you use clojurebot
23:54jli(doc str)
23:54clojurebot"([] [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:54sridquotemstr: yet another elisper learning clojure?
23:55symbolequotemstr: foo can refer to a Var or a function. It's not clear that it shouldn't be allowed.
23:55quotemstrsrid: And CLer. :-)
23:55quotemstrsrid: The FORMAT incantation just wasn't coming to mind.
23:55sridquotemstr: the "quick ref" at clojuredocs.org is pretty handy
23:56quotemstr(~S maybe?)
23:56sridif you look at the 'format' docs at clojuredocs.org it links to the java docs with full format spec
23:56jlithere's also clojure.core/format
23:56jli(doc format)
23:56clojurebot"([fmt & args]); Formats a string using java.lang.String.format, see java.util.Formatter for format string syntax"
23:57sridyes, 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)