#clojure logs

2009-12-24

00:00fanaticoas well as the comments on fogus's blog.
00:00tomojI don't understand why it's complaining about bytes... I'm not even using it :(
00:00devlinsfAh
00:02devlinsfchouser: ping
00:11akingtomoj: clojure 1.1 has a new defn for bytes - you'll need to remove it from agent.
00:11devlinsfaking: good catch!
00:15tomojaking: ooh! thanks
00:16akingprobably not remove it from http/agent.clj but rename it - doesn't look to do the same thing as core's bytes
00:17tomojI guess http.agent should be updated
00:20tomojhmm.. not sure how to get leiningen to use my patched contrib
00:23hiredmanswing is truely a torture devised to destroy me
00:24devlinsfhiredman: sometimes I wonder if Gosling gets paid a nickel every time a developer swears
00:25liebke` hiredman: what are you building with Swing?
00:25hiredmanI'm rewriting my repl
00:26akingtomoj: I'd suggest just overwritting the existing control jav under lib - seems to work for me (don't run 'lein deps' though)
00:26aking contrib*
00:26liebke`ah, excellent. I'm really interested in having a gui repl. I hope your luck with Swing improves :-)
00:26hiredmanthe stuff I was doing to scroll the scrollpane down to the bottom in the previous iteration does not seem to work now
00:27hiredmanhttp://www.thelastcitadel.com/images/Screenshot-Clojure.png
00:27hiredmanfrom the previous iteration
00:27devlinsfhiredman: Why not use a JTextArea?
00:27hiredmanbecause I want to render arbitrary stuff
00:27devlinsfOr JPanel *in* the scroll pane
00:28hiredmanI do have a JPanel in the scrollpane
00:28devlinsfLet JScrollPane do the work
00:28liebke`very cool! inline images, that would be awesome for Incanter
00:28hiredmandevlinsf: jscrollpane does no work
00:28devlinsfAnd are you just adding labels?
00:28hiredmanno
00:28devlinsfHow come?
00:28hiredmanI have a jscrollpane
00:28hiredmanin it is a jpanel
00:29devlinsfRight
00:29hiredmanto this jpanel I am adding arbitrary jcomponents
00:29devlinsfAnd it's not working?
00:29devlinsfHmm...
00:29hiredmanand I have the layout for the jpanel set to flowlayout
00:29hiredmanwait
00:29hiredmanno, box layout?
00:29hiredmananyway it lays stuff out downwards
00:29devlinsfRight
00:29hiredmanand the scrollpane does scroll
00:30devlinsfHmmm...
00:30hiredmanbut the keyword, in my description which you seem to have missed is: autoscroll
00:30devlinsfLike any other REPL
00:31hiredmanpreviously I was getting the visibleRect and then using scrollToVisibleRect on the viewport
00:31hiredmanbut it doesn't apear to work now
00:32devlinsfOkay, you've got me
00:32devlinsfStupid swing
00:33devlinsfIf I understand you correctly, you've tried manipulating the JViewport?
00:34devlinsfHmmm... I know I've set the viewport manually before
00:34akingtomoj: which dependency are you using for clojure-contrib in your project.clj file? The latest contrib already has a fix in for it
00:34devlinsfIf I find the code, I'll let you know
00:34devlinsf*set programatically
00:34hiredmandevlinsf: I have too, and it worked last time, but now it doesn't
00:34devlinsfHuh
00:35devlinsfWierd
00:35hiredman:|
00:35devlinsfhave you set it in Clojure before?
00:36devlinsfMy experience was in normal Java
00:36hiredmanthis was in clojure
00:36hiredmanI have the code right here
00:36hiredmanit's like a page up in my editor
00:36devlinsfNo f'ing clue, man
00:37devlinsfReset the REPL? Stranger things have worked
00:40tomojaking: oh, great
00:40tomojI guess
00:40tomojI guess I just need to update, then
00:41tomojis [org.clojure/clojure-contrib "1.0-SNAPSHOT"] right?
00:41akingtomoj: I'm using: [org.clojure/clojure-contrib "1.1.0-master-SNAPSHOT"]
00:42tomojthanks
00:45tomojhmm.. seems like that didn't fix it :(
00:47akingtomoj: try 'lein clean' and 'lein deps' - maybe it's still picking up the old one?
00:49tomojaking: ah, my fault, I had my manually installed jars dumped in there too
00:49tomojaking: works now, thanks for your help
00:50akingtomoj: np - I'm still just learning leiningen too :)
00:51lucidrains> If i have had no exposure to functional programming before, should i first jump into clojure or start with haskell?
00:51tomojany lisp exposure?
00:52lucidrainsnope
00:52lucidrainsis Lisp like the grandfather of all these languages?
00:53tomojeh, I dunno
00:54tomojclojure seems like less of a brainfuck to me, but I already was comfortable with lisp
00:54tomojdon't need to worry about types as much, but that might not be a good thing either :)
00:58mitchellhWhats the difference between "sync" and "dosync" ? I see that "sync" has flags TBD but what would be the purpose of using it in code now vs. dosync?
00:59tomojI think it's just there for future use
01:00mitchellhAlrighty
01:00hiredmanuse dosync
01:05mitchellhhiredman: Any specific reasoning other than avoiding the TBD?
01:08hiredmanbecause it's not used
01:08hiredmansync is a primitive and provides some room for future use, but no one uses it
01:09hiredman2009:Nov:17:03:44:57 rhickey : prefer dosync for now
01:09mitchellhhiredman: Thanks, I was only poking about it because I'm reading rich's ant.clj file and he used "sync" everywhere
01:10tomojthat was before dosync existed I guess
01:12mitchellhFigured
01:12mitchellhJust was making sure :)
01:21hiredmanI think I am closing in on the issue
01:25KirinDaveUgh, so you can't use netty without a java class?
01:26KirinDaveFor annotations? I mean you really simply cannot
03:38maaclWhy does lein fail to download clojure-1.1.0-alpha-SNAPSHOT.jar ?
03:43timothypratley"alpha" is now "master" I think
04:04notostracayes! I got counterclockwise to create working executable jars!
04:05notostracathe only caveat is that every library the app uses must be in the same folder
04:05notostraca(as the jar)
04:06notostracai was working at it so long that I don't know if i can reproduce the steps though
04:37G0SUBwhat should be the right type hint for a java fn that takes Collection<String> ?
04:41hiredmanG0SUB: #^Collection
04:41G0SUBhiredman: figured that out just now. many thanks.
04:55bOR_Trying to figure out how I can change the settings of the slime-connect called jvm (mainly -Xmx). While i'm looking, does anyone in here know the solution?
05:02vybOR_: See slime-lisp-implementations variable.
05:03vyC-h v slime-lisp-implementations
05:03bOR_thanks :).
05:08bOR_(swank-clojure-extra-vm-args '("-server" "-Xmx1024M"))
05:10bOR_hmm. but putting that in my .emacs won't make much sense if I start my swank using leiningen.
05:12bOR_I'll solve that problem later.
05:12vybOR_: You told SLIME, not leniningen. SLIME configuration will only affect the vms fired up by SLIME. For lenininininingen,... I have no idea.
05:13bOR_misunderstanding there then. You still connect to the leiningen swank from within emacs using M-x slime-connect.
05:13bOR_thanks for the pointer though :).
09:51samlhey, how can I get documentation of reader macro?
09:51saml(doc ') is error
09:51clojurebotUnmatched delimiter: )
09:54hoecksaml: http://clojure.org/reader
09:54samlso no way to do it in the repl
09:54samlah user cannot define reader macro anyways!
09:55hoecksaml: you may try sth like backquote and see into what the reader macro expands to
09:56saml(~')
09:56hoecksaml: but often those are special forms, documented only on the clojure page
09:56hoeck,`'a
09:56clojurebot(quote sandbox/a)
09:57samlcoolz thanks hoeck
10:34hamzaguys, if a java call requires 2 variables, and i have a vector of [val1 val2] is there a shorter way to call the function besides, (.call obj (first vec) (second vec))?
10:55samlhey can emacs do auto completion? what's the keyboard shortcut (using Clojure Box on windows)
10:56samli can press TAB to get auto completion in repl. but i'm not sure if that's possible in editor
11:00Hunsaml: M-Tab
11:00Hunif your window manager eats the M, use Escape Tab
11:00samlHun, yah but when I do Alt-Tab, window manager eats it
11:00Hun;)
11:00samlEscape-Tab minimizes the window
11:01Hunthen try C-M-i
11:01samloh escape-tab works
11:01samlhaha awkward key combo i should get used to
11:01samlC-h k will tell me what command it is. and i can remap!
11:02Hunyep
11:03Hun try M-x customize-variable slime-complete-symbol-function
11:03Hunin CL i use compound, which is awesome - you can complete mvb => multiple-value-bind
11:04samlthat did not let me set key binding. i should google it
11:05samldoes emacs have word completion? not related to clojure but using whatever is written in the buffer
11:05hamzayes M-. will complete anything..
11:05Hunthat can be done with hippie-expand
11:06Huni bind that to M-/
11:06Hunit can complete pretty much anything, using heuristics. it searches through buffers, filesystems, dictionarys, ...
11:07samloh C-c Tab is already slime-complete-symbol
11:08samlwow M-/ works
11:11jburdTry using the auto-complete.el package from the emacswiki. You won't ever need to hit M-/ again.
11:12samltoo much to learn!
11:25saml,``'a
11:25clojurebot(clojure.core/seq (clojure.core/concat (clojure.core/list (quote quote)) (clojure.core/list (quote sandbox/a))))
11:25samlwheeeeeeeee
11:28spariev__hi, anyone using enclojure ? is there any keybinding to quickly switch from editor to project repl ?
11:37saml,(defn foo [{x #(:x %1)}] (println "Hello" x)) (foo {:x "u"})
11:37clojurebotDENIED
11:40saml,(let [{x #(:x %1)} {:x "u"}] (println "Hello" x))
11:40clojurebotHello nil
11:40samlwhy can't i do that?
11:42the-kenny,(let [x #(:x %1) {:x "u"}] (println "Hello" x))
11:42clojurebotjava.lang.IllegalArgumentException: let requires an even number of forms in binding vector
11:42the-kennyoops
11:49jweissin the ns macro, :import section, anyone know how to import from the default package?
11:49jweissjust putting the classname doesn't work, it thinks that's the pkg name
11:50the-kennyjweiss: What's the "default package"?
11:51jweissthe-kenny: one at the toplevel, with no package name
11:51the-kennyjweiss: hm.. I'd look how the generated .class is named.. but isn't using the default package discouraged?
11:52jweissthe-kenny: yes. but i'm using a password hashing lib that is just one class, and they didn't put it in a package
11:52jweissso rather than rebuilding it i was just gonna try to import it as-is
11:52the-kennyjweiss: Found in Google: "You can’t use classes in the default package from a named package."
11:52jweissthe-kenny: the class is just BCrypt.class
11:53jweissthe-kenny: what does that mean "from a named package"
11:53the-kennyjweiss: From any other package than the default one
11:53jweissthe-kenny: but i'm calling it from clojure. clojure doesn't have packages
11:53the-kenny(In clojure for example user, clojure.contrib.seq-utils etc. etc)
11:54jweissoh, namespace == package?
11:54jweissdid not know that...
11:54the-kennyhm.. I think so
11:54the-kennyI'm not absolutely sure
11:54jweissbah, i guess i'm just gonna repackage it, will just take a minute and i gotta restart slime, but whateva
11:54jweissthanks
11:54samlspariev__, i just installed netbeans. go to Tools->Options->Keymap (tab) and search for repl
11:55samlfind Netbeans IDE Repl under Window category
11:55samlassign shortcut Ctrl+Alt+0
11:55samlCtrl+0 goes to editor
12:00spariev__saml, thanks, I missed that. Actually, I' using Project Repl with my classpath, and there are no shortcuts for it. well, at least I can switch back to editor faster now
12:01samlno idea :P
12:25srirampc?
12:33fliebelWhat could possibly be wrong with this line? It's giving java.lang.IllegalArgumentException: Key must be integer: (writer (map #(template % @pages (first args) (second args)) @pages))
13:08joshua-choiA question. I have a sequence "s". To get the first element in it that does not fulfill a function "pred", I do (first (drop-while pred s)). How, then, can I best get the element *right before* that one?
13:09samlsplit the list at first pred. and get the last element of the first list?
13:11fliebelMaybe reduce is better for this
13:11joshua-choiWell, split uses filter. Unfortunately, I need to get the element right before the *first* element that doesn't fulfill the predicate, so using filter or split doesn't work
13:11joshua-choiI think
13:11fliebelWith reduce you can return the next item until the next item is true and the return the other
13:11joshua-choifliebel: How might you use reduce?
13:11joshua-choiYeah
13:12fliebelone moment....
13:12joshua-choiThat would work, but it would always go through the entire sequence
13:13joshua-choiUsing drop-while in (first (drop-while pred s)) stops the sequence immediately when the proper element is found, since drop-while is lazy
13:13joshua-choiIt'd be great if there was a similar way for getting the element before that first element
13:13fliebel(reduce #(if %2 %1 %2) [false false true false])
13:14joshua-choi,(reduce #(if %2 %1 %2) [false false true false])
13:14clojurebotfalse
13:15fliebel(reduce irc://irc.freenode.net/#(if (= :c %2) %1 %2) [:a :b :c :d])
13:15fliebel,(reduce irc://irc.freenode.net/#(if (= :c %2) %1 %2) [:a :b :c :d])
13:15clojurebotjava.lang.ClassNotFoundException: irc://irc.freenode.net
13:16joshua-choiIs there a way, though, that doesn't have to go through the whole sequences? The sequences I'm dealing with are going to be very large
13:16fliebelI don't know, I'm not a Clojure expert, you see...
13:16samlhow do you zip two lists?
13:17saml(1 2 3) ==> ((1 2) (2 3))
13:17fliebelI'm — without success so far — trying to solve an very unhelpful java error.
13:17samlzip the list with its tail and modify pred
13:17samlto test second element of the list
13:18samlif you find it, then first element of the list is previous element
13:21fliebelHow can I find out where an error comes from?
13:21fliebel(generator.clj:0) is obviously not right...
13:28chouser,(some (fn [[a b]] (when (odd? b) a)) (partition 2 1 [2 4 6 8 9 10 11])))
13:28clojurebot8
13:29chouserjoshua-choi: that's for you
13:29joshua-choiExcellent
13:29chousersaml: pretty much your idea. 'partition' as a sort of pre-packaged zip-with-tail
13:30chouserfliebel: does generator.clj start with an 'ns' form?
13:30fliebelchouser: yes
13:30fliebelchouser: but nothing changed with that since it stopped working
13:30chouserthat's usually what the :0 indicates. Haven't tried to figure out why.
13:31fliebelchouser: strange, but I actually think I found out which line it is by removing stuff…
13:32chouseryeah. :-/
13:32aravindhi, I need some help getting slime to work.. I am using the latest git versions of clojure-mode and swank-clojure, when I start slimme, the repl starts okay, but slime can't talk to it and fails with "Error in timer" slime-attempt-connection...
13:32fliebelchouser: Any idea what "java.lang.IllegalArgumentException: Key must be integer" might mean in a for expression?
13:33mitchellharavind: I'll show you my .emacs with the setup and maybe that'll help
13:33aravindmitchellh: cool!
13:34mitchellharavind: https://gist.github.com/7f060cbd1879927e3538
13:34mitchellharavind: Thats everything that makes it work for me, you should be able to glean from the paths how everything is laid out
13:34mitchellharavind: With that, i simply do M-x slime and it works
13:35chouserfliebel: trying do a lookup in a vector with a non-integer
13:35aravindmitchellh: okay, let me try that setup.
13:37fliebelchouser: I'm looking at some functions now… but without helpful error reporting it's not easy...
13:39aravindmitchellh: did you checkout the latest slime from github as well?
13:39aravindmitchellh: I am using the one that comes with emacs
13:39aravindoh :(
13:43mattreplaravind: slime changes fairly quickly, it's best to grab the latest
13:46fliebelIs future suitable for doing io?
13:46aravindmattrepl: I would.. but there is a big fat warning that the latest slime may not work with clojure, since its designed more for CLs
13:47mattreplaravind: where at?
13:47aravindmattrepl: http://groups.google.com/group/clojure/browse_thread/thread/4960adce009d4760/b1b259efc229cad0?lnk=gst&amp;q=swank+2009+dec#b1b259efc229cad0
13:48aravindI wish something like this would be simpler..
13:49mitchellharavind: Um… no, from CVS
13:49mitchellharavind: cvs -d :pserver:anonymous:anonymous@common-lisp.net:/project/slime/cvsroot co slime
13:49mitchellharavind: straight into my emacs.d includes folder
13:49mattreplaravind: ah, ok. yes that does happen sometimes.
13:49mattreplELPA is a good suggestion
13:50aravindI have never used that, so no clue how elpa works..
13:50mattreplthe link technomancy provided has installation instructions: http://tromey.com/elpa/
13:51aravindmattrepl: yeah, I am reading about it now.. a lot of folks seem to recommend it
13:52mattreplI had been managing my own packages for awhile and was reluctant to move from "good enough" to elpa - but it does work and streamlines package management
13:53aravindmattrepl: yeah, my concern exactly.. I am in the habit of just getting whatever .el files are needed and sticking them in a directory.
13:54mattreplbe ready to spend a few moments cleaning out any old packages once you've re-installed them with ELPA, but that's straightforward
14:05aravindmattrepl: okay, I installed clojure-mode, swank-clojure and slime with the elpa thingie and I still get the same error I did when I started out.
14:05mattrepldid you remove previous versions?
14:05aravindwhich makes me suspect that something upstream is broken.
14:05aravindmattrepl: I did.
14:06mattreplhmm, anything interesting in *inferior-lisp* buffer? if so, please pastebin or msg
14:08JonSmithsorry,what is the error?
14:08aravindmattrepl: http://pastebin.com/d193f5732 and I get a backtrace with this - http://pastebin.com/d44bdf41e
14:13aravindyou guys think its still my env thats screwy?
14:14mattreplnot sure, was googling around a bit for anything related, nothing helpful turning up
14:15mattreplooc, what emacs version and OS?
14:16aravindmattrepl: 23.1.1 and debian
14:20JonSmithhmm i'm using emacs 22
14:20JonSmithidk if that matters
14:21aravindwell.. at least now I know the problem wasn't with my original setup.
14:22ieureIs there some way to make my code dump me into SLDB when I’m using slime/swank-clojure?
14:23ieureIt isn’t throwing an exception, but it’s not working and I want to step through to figure out why.
14:26joshua-choiWhat's the difference between repeat and replicate, other than repeat's n parameter defaulting to infinity?
14:27devlinsfjoshua-choi: I think replicate is going to be deprecated
14:27devlinsfjoshua-choi: Not 100% sure, though
14:28joshua-choiHmm, I see
14:44olerixmannhi
14:44olerixmannon christmas eve
14:45olerixmanni have a problem gettinge resources from a jar file...
14:45olerixmannmaybe someone can give me a hint why i always get zero pointer-exceptions
14:45olerixmanni try it this way:
14:46olerixmann (with-in-str (slurp (.. 'this (getClass) (getResource (str "templates/" schtring)))) (read))
14:46olerixmannschtring is a string
14:48JonSmithdid you try printing out the different arguments to the repl and seeing which one is nil?
14:48JonSmithmy guess would be it has something to do with 'this, but really is hard to tell
14:48shoover``aravind: Any chance your machine has really tight security such that you couldn't even connect to a socket on a localhost port?
14:48aravindshoover``: hmmm.. :) thats possible
14:49aravindI didn't think of that.. but yeah, let me check
14:49shoover``aravind: because the one paste says swank opened the socket, but the phrase "Connection refused" is in your debugger paste
14:50olerixmanngetResource returns nil
14:50olerixmann..
14:50aravindshoover``: phew okay.. no that wasn't it.
14:51aravindshoover``: I disabled my firewall and still same error.
14:51aravindI would have felt really stupid if that was the problem!
14:52olerixmannmaybe someone has an example of loading anything from the application jar?
14:54JonSmithhum
14:55JonSmiththe thing is it should really be the same as doing it from java
14:55JonSmithit might be a placement issue
14:55JonSmithhttp://www.velocityreviews.com/forums/t134544-load-images-and-text-file-from-jar-file.html
14:56olerixmannthx
14:56JonSmithif you are getting an error it might be useful to do (.printStackTrace *e)
14:58olerixmannits just the zero pointer except from the getResource, but i'm trying with leading slash now :)
14:59hiredmanolerixmann: null point
14:59hiredmaner
14:59JonSmithyeah, hopefully it will be the same as the java problem
15:00hiredmanusing with-in-str and read and slurp is horrible
15:00hiredman(binding [*in* some-reader] (read))
15:03olerixmannreading this way works
15:03hiredmanbut is is horrible
15:03olerixmannyeah, maybe
15:03olerixmanni have some other problems ;)
15:04hiredmanwell, if you code in that style I am not surprised
15:05olerixmanni don't think its so ugly
15:05olerixmannwhat is the with-in-str macro for?
15:05olerixmannif not for this
15:05olerixmannsorry, my english is not as good as i want it to be
15:05hiredmanthe ugliness is from reading the whole file into memory as a string
15:06olerixmannok
15:06olerixmannits just a few lines
15:06olerixmannnot that bad
15:06hiredmanit's a bad habit
15:06hiredmansmells of php
15:07olerixmann;)
15:07olerixmannno php on my side
15:10olerixmannseems to work now, thanks
15:10shoover``aravind: I don't know what else to check, but there's definitely a networking issue. Either that socket isn't really open or you can't get to it. That's why that "connection refused" is there
15:10hiredmanwhat you want to do is someting like (with-open [o (-> (ClassLoader/getSystemClassLoader) (.getResouceAsStream "Whatever") InputStreamReader. PushbackReader. BufferedReader.)] (binding [*in* o] (read)))
15:11olerixmannbut i always get strange errors when compiling, but it works anyways....
15:11hiredmanduck streams should take care of all those readers
15:11olerixmannok, thanks
15:11olerixmanni'll change that
15:11aravindshoover``: yeah.. you are probably right.
15:11aravindshoover``: I am trying to go down to the elisp stuff thats connecting and checking if that works.
15:12aravindshoover``: thanks for looking into it though.
15:16shoover``aravind: here's some test code you can try: http://paste.bighugh.com/scratch.html
15:17shoover``(thanks, technomancy, scpaste rules)
15:17hiredmanwhat about the java side?
15:17hiredmandoes the jvm start and is it listening?
15:23aravindhiredman: yeah, the java side is up and listening
15:24aravindalthough, it quits listening once you connect to it and quit (from telnet)
15:31aravindshoover``: that test code isn't working on my box..
15:32aravinda plain telnet to that port works, but within emacs it fails.
15:33aravindshoover``: fails with '(file-error "make client process failed" "Connection refused" :name "crino" :buffer "crino" :host "127.0.0.1" :service 8888)'
15:34shoover``aravind: I dunno, something's hamstringing your emacs
15:36q2Any tips on an efficient case-insensitive lookup by key against a map?
15:37q2given: {"Foo" "bar"} lookup "foo" ==> "bar"
15:38LauJensen(filter #(= (tolower x) (tolower y))) is probably near-optimal
15:41q2lau: thanks. what lib is tolower in?
15:41LauJensen,(.toLower "HI THERE")
15:41clojurebotjava.lang.IllegalArgumentException: No matching field found: toLower for class java.lang.String
15:41LauJensen,(.toLowerCase "HI THERE")
15:41clojurebot"hi there"
15:41q2ah java's. got it.
15:41LauJensenah.. :)
15:50q2lau: so close! a lowercase method that doesn't bomb on null would be more awesome :)
15:51LauJensenCan you write an example of what you want/what u have?
15:51q2lowercase what comes out of a regex prior to the map lookup. regex can return NIL
15:51q2so (. toLowerCase nil) --> bad
15:54LauJensen(filter #(when-let [match (re-seq #"...")] (= (.toLowerCase match) (.toLowerCase %)))...
15:54LauJensenSo that kind of thing?
15:55q2yeah that's the basic idea
15:55LauJensenThat will work then
16:05aravindI think I figured it out..
16:05aravindshoover``: it appears that my latest kernel updates (and/or clojure updates) enabled and started using ipv6 on my box.
16:06aravindand the clojure repl (created by slime) was listening on a ipv6 port, but slime connection was trying to talk to the ipv4 address.
16:06aravinddisabled ipv6, and stuff seems to be working correctly now.
16:06aravindwhat a waste of time!
16:06q2lau: thanks. you are right. the key difference was when-let vs just let :)
16:11q2one last silly REPL question. how to abort the query I'm writing without a ctrl c or ctrl d -- which exits the repl
16:33LauJensenYou mean if you've started a lengthy computation and you want to abort halfway through, still keeping the REPL?
16:33q2yup
16:33LauJensenSorry I dont think thats possible
16:34q2ah, that's a shame.
16:34chouserrepl-utils add-break-thread!
16:34LauJensen~source add-break-thread!
16:34q2excellent!
16:35LauJensenq2, sorry about that bit of bad advice
16:35chouserwell, using add-break-thread! is techincally bad advice -- uses deprecated Java features.
16:35chouseron the other hand, it generally works. so ...
16:36q2no worries. i'm still very much a novice, excuse the silly questions.
16:37q2thanks chouser. that works quite well.
17:10somniumcan lein be used to compile .java?
17:12LauJensenIs there a definitive paper on Write Skew lying around somewhere ?
17:14chouserwikipedia has an article. might have useful links too, if it's content is insufficient.
17:15arohner,(deftype my-type [foo bar])
17:15clojurebotDENIED
17:15arohnernice
17:16somniumchouser: have you looked at the javascript-compiler it that new google closure thing?
17:16arohneranyways, it appears you can't use merge on deftypes
17:17LauJensenthanks chouser I'll have a look again, I only found a small reference on the snapshot iso page
17:17arohnereven if they implement IPersistentMap
17:17somniumarohner: if you include IPersistentMap in interfaces you can use conj
17:17arohnerlisppaste8: url
17:17lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
17:17somniumsome of the other fns seem to rely on associative/collection
17:18arohnermerge uses conj, and it's still not working for me
17:18arohnerone sec, I'll paste this
17:19somniumarohner: what error? and try (conj atype [:foo :bar])
17:19lisppaste8arohner pasted "merge deftypes?" at http://paste.lisp.org/display/92600
17:20arohnerassoc works, conj does not
17:21somniumarohner: really, I had the opposite last time I tried
17:21somniumI guess the edge is bleeding, so Ill stop talking :)
17:22liebkesomnium: there is a javac plugin for lein: http://github.com/antoniogarrote/lein-javac
17:23somniumliebke: great! thanks
17:24arohnerhmm, (conj (Foo 1 2) [:c 3]) works
17:40chousersomnium: I'm aware of its existence, but I haven't really looked at it.
17:42somniumchouser: it turned the gensym mess created by my still-broken compiler into frighteningly readable javascript. It might be interesting to try it on clojurescript.
18:10chousersomnium: interesting. I wasn't expecting it to generate *readable* js.
18:13somniumchouser: for locals it assigns vars like a b c, I was unrolling function calls for arg evaluation and getting big nests of curly braces and var ..., it cut out all the redundancy
18:14somniumchouser: seems like a big win if any clojure->js project can worry only about semantics and let google's optimizer do the rest
18:15chouseryes, I agree
18:25q2any tips on returning the hierarchy for any given classs?
18:25q2all interfaces / classes it implements / inherits
18:27somnium,(ancestors String)
18:27clojurebot#{java.lang.Object java.lang.Comparable java.io.Serializable :clojure.contrib.generic/any java.lang.CharSequence}
18:28q2thanks
18:59sdeobaldAm I blind or is there no way to specify an output directory to clojure.lang.Compile?
19:04mikehincheysdeobald: *compile-path*
19:04sdeobaldmikehinchey:
19:04sdeobaldthanks!
19:13sdeobaldmikehinchey: Hmm. I'm not quite sure how to apply that to the Java world when doing this: `java -Dclojure.compile.path=src -cp lib/clojure.jar:src clojure.lang.Compile'
19:14sdeobaldOr should I be using lein or something these days for compiling and creating jars?
19:15dliebkeI recommend lein (or mvn)
19:32ieureHm. So if I have a Java instance in an atom… How do I use that? Do I have to let-bind it?
19:32hiredman:(
19:32ieuree.g. I was doing (.writeBytes stream)
19:32hiredmanyou have to deref the atom
19:32ieureBut put that in a map in an atom, then changed it to (.writeBytes (:stream @atom-obj))
19:32ieureBut that gives me: No matching method found: writeBytes for class clojure.lang.Atom
19:33hiredmanyou must have the stream wrapped in an atom too
19:33ieurehiredman, I know, just wondering if I have to deref it in a let-binding before trying to call the method, or if there’s a better way, or if I’m doing it wrong.
19:33hiredman(atom {:stream (atom some-stream)})
19:33hiredmanor something
19:33ieureNo.
19:34hiredmanieure: that is what the exception says you have
19:35hiredmanthe exception says the result of (:stream @atom-obj) is an atom
19:35hiredmanand since atom-obj is an atom, that means you have nested atoms
19:37ieureOkay - I see what I did.
19:37ieureThanks.
19:58q2mmm (try (catch)) is killing performance. there something faster than (try) ?
19:58q2i don't care what exception it is. i just want to do an alternative.
20:00slashus2Killing performance?
20:01q2yeah. consider this: (defn missing?3 [x] (try (empty? x) (catch Exception _ (nil? x))))
20:01q2that above line is 3800 times slower than
20:02q2this line here: (defn missing?4 [x] (or (and (or (coll? x) (seq? x) (string? x)) (empty? x)) (nil? x)))
20:02q2the idea is for (missing?) to take any param and tell you if its NULL or empty
20:02q2er nil
20:03q2so "" () {} [] nil all eval to true
20:03q2maybe it's just best to check for each of those cases, but heh.
20:03q2the overhead with try catch is still clear.
20:04KirinDaveq2: It's slower even if you don't hit the exception case?
20:04q2yes
20:05q2actually mayb enot.
20:05q2but in this case I expect 50% of the calls to throw the exception
20:05q2be nice to have an alternate to (try (catch)) that simple stops the exception from generating, replacing it with an expr.
20:06q2guess it's java limitation?
20:06KirinDaveq2: This just in: exceptions are expensive. :)
20:07KirinDaveq2: Does (or (nil? x) (empty? x)) work?
20:07q2i know :) it would be nice to have a mode that turns off exceptions for certain calls :) so rather than generate one, do X
20:07q2no
20:07q2because empty? generates an exception
20:08q2if you pass it an integer
20:08KirinDaveSo yeah it's your second example.
20:08KirinDaveI'm surprised empty? lets that happen, tbh. It should say false for ints.
20:08q2options are: rewrite missing?, rewrite empty?
20:08q2yeah it shouldn't not intuitive that way
20:08KirinDaveWell...
20:09q2or ask the irc about other exception handling tricks!
20:09KirinDaveI'd profile a multiple dispatch version.
20:09q2i did
20:09KirinDaveHow much slower was that?
20:09q2it is slower than the second option
20:09KirinDaveHuh. Well then what's wrong with the first? ;)
20:09q2and results in 3 defmultis hehe
20:10q2i don't like it because it's still pretty slow
20:10q2php is beating me out
20:10q2lol
20:10KirinDave(defn missing? [x]   (or    (and (or (coll? x) (seq? x) (string? x)) (empty? x))    (nil? x)))
20:10KirinDave?
20:10q2that's the fastest one
20:10KirinDaveYeah. What's wrong with that besides the order in which you call it?
20:10q2takes over 1 second to do 9M calls
20:11q2the same in something slow like PHP, takes about 0.7 seconds
20:11KirinDaveUm, so?
20:11q2i switchd to clojure for speed :)
20:11q2for this particular task
20:11q2oh well
20:11KirinDaveThere is always the maybe-m monad
20:11q2this is the one bottleneck in the application that is slower. but i'll continue working on it.
20:12q2i should check that out. the problem seems simple enough though.
20:12KirinDaveYou could basically eliminate any cases where nil enters the chain.
20:13KirinDaveAnd the constructions used in clojure are fairly fast, esp for the maybe-m monad.
20:14KirinDaveq2: also, if speed is _really_ important on this
20:15KirinDaveq2: You've written your fastest version in the slowest possible way. Write it to short circuit earlier.
20:15q2yeah reworking the cases is an option. or not using empty? maybe, but writing my own. looks like empty just calls: (not (seq x))
20:15KirinDave(and (not (nil? x)) ...)
20:15q2right. i don't understand the use case yet. but i think nil? and empty? cases are about 50/50
20:16KirinDaveIf that's the case, then inverting the form of the logic will get you big benefits.
20:16q2and i'm too lazy to figure each case hehe
20:16KirinDaveBut seriously
20:16KirinDaveif factoring out nils in a chain of operations is a big deal, that's pretty much exactly what the maybe-m is for.
20:16KirinDaveANd it's just function calls, it will be fast.
20:17q2i like that notion. time to learn monads...
20:17KirinDaveThere are 2 great tutorials I've been wrestling with.
20:17q2Neat. Got links?
20:17KirinDaveFor me, it's not easy.
20:17KirinDavehttp://intensivesystems.net/tutorials.html is for one set
20:17KirinDave(That work on compojure is epic)
20:18KirinDaveAnd the other one: http://onclojure.com/2009/03/05/a-monad-tutorial-for-clojure-programmers-part-1/
20:18q2Thanks Kirin.
20:19KirinDaveI'm trying to see if I can use the state monad to use nio to make a faster server-socket library, myself.
20:19KirinDaveThe current server-socket doesn't scale very well.
20:19q2I'll share the monad when I get around to it. If it turns out to be the best.
20:19KirinDaveSure.
20:19KirinDaveGood luck.
20:19q2Good luck to you too.
20:32LuytI'm still trying to understand the concept of monads. Maybe that these tutorials will help ;-)
20:45srirampc?
21:08pdkwould a clojure struct be more lightweight with its memory footprint than a java object when using both for value semantics for the same things
21:08pdke.g. if i had a Point class in java to store a 3d coordinate as three doubles and i did the same with a clojure struct, could i expect a smaller memory footprint and perhaps cleaner code with the struct
21:12hiredmanpdk: Point will be more light weight
21:12hiredmanbut it is not immutable :|
21:13hiredmandatatypes (from the new branch) should be the same or less
21:13pdkhm is there information on clojure memory consumption for these sorts of details
21:13pdki mean i know it's nitpicking and with persistency you gotta get used to it but :p
21:19hiredmanpdk: best to run your code through some kind of profiler
21:19q1hired: what profiler would you recommend?
21:19pdki assume that most profilers like jhat would work with clojure code after compiling it to class files and still produce useful results without much extra fuss?
21:21hiredmanrhickey has mentioned yourkit
21:21pdkhm google turned up a blog post on jvisualm + clojure q1
21:21hiredmanyourkit costs money (but there is an evaluation copy)
21:23hiredmanI've yet to be in a situation where I needed to profile
21:23pdkhmm
21:23pdkq1 jhat is bundled with the jdk and according to this blog post jvisualm is as well with more recent versions
21:23pdksoooo time to update jdk!
21:25hiredmangood idea, I've seen reports of pretty significat speed ups just from switching to a newer jvm
21:27pdkstill jdk 6 here at least but hey
21:27hiredmanyeah
21:28hiredman5 -> 6
21:32pdkwhat is the windows kernel installation of the jre supposed to be
21:32hiredmanerm
21:32hiredmanI don't think the windows "kernel" has a jre
21:34pdkon the jre download page from java.sun.com it lists a "windows kernel installation" download, not sure what that's about
21:35pdkcertainly the obvious meaning of kernel here seems odd
21:38hiredmanhttp://java.sun.com/javase/6/docs/technotes/guides/jweb/otherFeatures/jre_install.html#kernel
21:56pdkgah
21:57pdkwhat's the right way to uninstall your old version of the jre/jdk again after update
21:59tomojanybody noticed lein-swank not putting src/ on the classpath?
22:44konranybody using both clojure and CL on Emacs? Will I run into trouble trying to install them?
22:48tolstoykonr: I doubt it. You can always just try it and see. ;)
22:48tolstoykonr: I start up swank by hand and use M-x slime-connect, which pretty much solves all the classpath issues for me.
22:49tolstoyI just make a little shell script that builds the classpath and starts swank.
22:49tolstoySeems like slime's smart enough to know which system it's attaching to.
22:50tomojkonr: here's my old config https://gist.github.com/a59bdb809b378b7f1da1
22:50tomojdunno if it will help
22:51konrtomoj, tolstoy: thanks, guys! I'm gonna play with it :)