#clojure logs

2010-05-03

00:02LeNsTRyep
00:03eliantoris it a right fold?
00:05defneliantor: http://gist.github.com/96861
00:05defnthat is
00:09eliantorbut it consumes the stack
00:09eliantordoes it work the same using trampoline?
00:42joshua-choiQuestion: does clojure.contrib.def/defalias work on macros? It doesn't seem to.
00:44_ato~def clojure.contrib.def/defalias
00:46_atohmm.. preserves metadata which should be the main thing
00:46joshua-choiYeah, I thought so too, but it doesn't seem to act correctly.
00:46joshua-choiCan I try it here?
00:47_atonah, def won't work with clojurebot
00:48_atoseems to work for me http://gist.github.com/387763
00:48_atoI haven't tried with git master though, there's been some changes to macros
00:50joshua-choiYes, I'll try git pull again for both clojure and contrib and see if that fixes it
00:52joshua-choi_ato: Pulling and rebuilding both clojure and contrib did not fix it for me
00:53joshua-choiTry using this macro instead: (defmacro a [x] `'~x)
00:53joshua-choiAnd (defalias b a) (b y).
00:59_atoah.. yep doens't seem to work with 1.2
00:59remleduffDo your compojure apps end up doing a ton of (str "/" var "/" var2) ?
01:06joshua-choiremleduff: Seems like there should be a helper method. At least (clojure.contrib.string/join "/"
01:06joshua-choiUgh, I pressed enter early
01:06joshua-choi_ato: Can you see the reason why? Should I file a ticket?
01:36Licenser_morning
02:09defnwhen i do something i a try/catch, if i am able to catch the error and fix what the problem is, will that then get evaluated?
02:10defni have something like:
02:10defn,(read-string "[Ljava.lang.String;")
02:10clojurebotjava.lang.RuntimeException: java.lang.Exception: EOF while reading
02:10defnhowever, more than just this case blows up the reader
02:10defnso id like to just:
02:11defn,(read-string "\" [Ljava.lang.String;\"")
02:11clojurebot" [Ljava.lang.String;"
02:11defnwhenever it catches
02:16Licenser_defn: why would you want that?
02:17defnwhile the reader doesnt like them, they are still helpful for some examples
02:17Licenser_(let [s "[Ljava.lang.String;"] (= (read-string (str \" s \")) s))
02:18Licenser_,(let [s "[Ljava.lang.String;"] (= (read-string (str \" s \")) s))
02:18clojurebottrue
02:18defndrop the ]
02:18Licenser_what]?
02:18Licenser_there is no ] in the string
02:18defnohh sorry, had to expand my window
02:19Licenser_[Ljava.langString is just a notation for a string array I think
02:19defnLicenser_: i know I can handle that specific case, but there are other cases ive run into like #<foo$bar>
02:19defni'd like to just quit thinking about that part of the equation and escape it as a string when it comes up
02:20defn"oh hey this didnt work!" -> make it a string
02:20Licenser_so you want to escape stuff within an expression if it fails?=
02:20defn-> now read it
02:20defni just want to escape the whole expression as a string when it fails
02:20defnand go about my business
02:20Licenser_but you already have the result of it
02:21defnright, but it's not pretty printed. I need to read-string on the code/results to pretty print them, some of the "good" results still blow up due to things like #<, [Ljava;, and other cases I'm probably not aware of
02:23Licenser_(read-string (escape-as-stringe code-string)) = code-string
02:23Licenser_defn: there is no difference
02:23defnyes, but that will escape everything i do as a string, and therefore no syntax highlighting will happen
02:23Licenser_it is just eating computation power
02:24Licenser_but "\" ...\"" is the same o.O it escapes everything as a sting
02:24Licenser_or do you want to escape like parts of the code string as a string
02:24Licenser_so (type [Lblabla;) to (type "Lblabla;")?
02:24vIkSiThmm, whats the best/most idiomatic method of implementing a while loop?
02:24vIkSiT(loop .. ) ?
02:24Licenser_vIkSiT: while?
02:25Licenser_(doc while)
02:25clojurebot"([test & body]); Repeatedly executes body while test expression is true. Presumes some side-effect will cause test to become false/nil. Returns nil"
02:25vIkSiTer weird. should look that up :)
02:25vIkSiTi couldn't find any docs for "clojur while loop" heh
02:25Licenser_$walton while
02:25sexpbotCommand not found. No entiendo lo que estás diciendo.
02:25Licenser_$example while
02:25sexpbotCommand not found. No entiendo lo que estás diciendo.
02:26Licenser_$oh go and die you stupid bopt
02:26sexpbotCommand not found. No entiendo lo que estás diciendo.
02:26vIkSiT:)
02:30ChousukevIkSiT: note that you need a side-effect in the condition for that to make any sense.
02:31ChousukeI suppose (while @running ...) is somewhat common
02:34Licenser_Chousuke: don't take me the joy of making vIkSiT do a infinit lopop :P
02:35Chousuke:P
02:41defnLicenser_: erm im not sure if i see what you're saying with respect to escaping with str
02:41defnLicenser_: if the string cannot be read by the reader and throws an exception I want to escape it as a string
02:42defn"\"foo\"" works where "foo" doesn't when it comes to read-string
02:42defn,(read-string "#<foo$bar")
02:42clojurebotjava.lang.RuntimeException: java.lang.Exception: Unreadable form
02:42defn,(read-string "\"#<foo$bar\"")
02:42clojurebot"#<foo$bar"
02:43Licenser_defn: do you notice that the result of (read-string "\"#<foo$bar\"") is exactly the unescaped string?
02:43Licenser_if it fails just don't use read-string at all
02:43defnit isn't always
02:44Licenser_yes it is unless you have a " in the middle of your string, then it breaks
02:44defnright, but that's yet another corner case -- because many of them do
02:44Licenser_assuming you escape your string correctly then the result is, by definition the same
02:45defn,(read-string "[{111 #<Ref@1bc7fae5: :somestruct>} {\"bob\" #<Ref@1bc7fae5: :somestruct>}]")
02:45clojurebotjava.lang.RuntimeException: java.lang.Exception: Unreadable form
02:45Licenser_you could use (identity ) to escape and read-string it
02:45defn,(read-string "\"[{111 #<Ref@1bc7fae5: :somestruct>} {\"bob\" #<Ref@1bc7fae5: :somestruct>}]\"")
02:45clojurebot"[{111 #<Ref@1bc7fae5: :somestruct>} {"
02:46defnthe reader is a harsh mistress
02:46Licenser_so having read-string and escape bill not only consume computation power for nothing but also add bugs ':p
02:46defnread-string is necessary though, im confused as to what you're saying
02:47Licenser_defn: I'm saying it is not
02:47Licenser_you can use identity instead of (read-string (str \" ... \"))
02:47Licenser_that saves yourself trouble and time :P
02:48defnthat doesn't make sense though?
02:48defn,(pprint (identity "foo"))
02:48clojurebot"foo"
02:48defn,(pprint (read-string "foo"))
02:48clojurebotfoo
02:48Licenser_yes thaqt is for a good case
02:48Licenser_but in a bad case you can use identity
02:49defnah-ha, i see what you mean now
02:49tomojthe problem is how to get to the bad cases
02:49tomojread-string doesn't give you any hooks
02:50tomojyou'd have to rebuild some of read-string
02:50Licenser_(let [s "bla bla"] (try (read-string s) (catch Exception _ (identity s)))
02:50Licenser_,(let [s "bla bla"] (try (read-string s) (catch Exception _ (identity s)))
02:50clojurebotLicenser_: It's greek to me.
02:50Licenser_,(let [s "bla bla"] (try (read-string s) (catch Exception _ (identity s)))
02:50clojurebotLicenser_: Titim gan éirí ort.
02:50Licenser_something like that
02:51defnLicenser_: so will that string in the catch be passed up to pprint that lies outside of your let?
02:51tomojI'd assume you want only the unreadable forms as strings, not the whole top-level form?
02:51defntomoj: the top-level is fine, actually
02:51tomojstrange, why?
02:51Licenser_(let [s "[bla bla"] (try (read-string s) (catch Exception _ (identity s))))
02:51defntomoj: most of them are pretty short
02:51Licenser_,(let [s "[bla bla"] (try (read-string s) (catch Exception _ (identity s))))
02:51clojurebotLicenser_: Huh?
02:52Licenser_welll that code works just not in clojurebot
02:52Licenser_$(let [s "[bla bla"] (try (read-string s) (catch Exception _ (identity s))))
02:52sexpbotresult: [bla bla
02:52tomojso.. any input which contains an unreadable form somewhere will just be passed straight through?
02:52defnsexpbot: yeah, they've already been evaluated in a sandbox, this is just output i want to pretty print
02:52defnit's just what they've been evaluated to isnt always something the reader likes
02:53defn#<foo$bar> for instance
02:53tomojso any of them which contain unreadable forms will be ugly printed?
02:53Licenser_why would you want to read the result of a evaluation?
02:53defnyeah, but out of 211 examples there are maybe 7 or 8 of them
02:54defnLicenser_: to pretty print it
02:54Licenser_defn: that isn't good
02:54Licenser_that will or might chane the result and that usually isn't what you want
02:54tomojwhen would it change the result?
02:55defnit should just read it as code and pprint it, it's not changing anything
02:56Licenser_,"#(+ 1 %)"
02:56clojurebot"#(+ 1 %)"
02:57tomojyou're doing this to the return values of code run by bots?
02:57Licenser_,(read-string "#(+ 1 %)"
02:57clojurebotEOF while reading
02:57Licenser_,(read-string "#(+ 1 %)")
02:57clojurebot(fn* [p1__13903] (+ 1 p1__13903))
02:57Licenser_in that case for instance
02:58Licenser_even worst, reader eval :P
02:59Licenser_which would rip a huge security hole in your code defn
03:01tomoj,(println "#=(println \"foo\")")
03:01clojurebot#=(println "foo")
03:01Licenser_now if you read that weeh!
03:02Licenser_tomoj: it'S not about printing it
03:02Licenser_'ss~ about read-string the result of an expression
03:02tomojI know
03:02tomojbut I think the source is bot output, right?
03:02Licenser_,"#=(println \"foo\")"
03:02clojurebot"#=(println \"foo\")"
03:02Licenser_now read-eval that :P
03:02tomojso we can just print out strings that contain whatever code we want to run on defn's machine
03:03Licenser_tomoj: yap
03:03defn? read-string doesn't eval the code though, does it?
03:04tomojindeed it does
03:04defndamn...
03:04tomojif it's reader eval
03:04defnthat sucks...
03:04tomoj(read-string "(println \"foo\")") is fine
03:04tomojbut (read-string "#=(println \"foo\")") will print
03:04defn#=... isn.t though
03:04defnwell I can just escape #= strings
03:04defnthat's not hard
03:05Licenser_defn: it still changes the results :(
03:06defnLicenser_: im confused, how?
03:06defnhttp://getclojure.org:8080/examples/dorun
03:06sexpbot"dorun"
03:07defnnotice example three is now formatted nicely using pprint and read-string
03:07defnyes you do get some weirdness with anonymous functions, but they are still largely readable
03:07Licenser_defn: it's still bad practice :P
03:07defnif i just get rid of the #= at the beginning of a string, wont that solve the problem?
03:07Licenser_no
03:08defnLicenser_: well then what is the elegant solution here, to not do it? i dont see how else to make this work
03:08tomojsuppose some code returns the string "[foo bar baz]"
03:08Licenser_that sho9uld be displayed as a string
03:08Licenser_defn: the sandbox already returns forms, you don't need to read-string them at all
03:08defnoh duh
03:08tomojyeah, and you'll get a vector
03:08Licenser_just don't turn them into a string :P
03:08tomojI feel like there are probably weirder examples
03:08defnyeah definitely, that makes perfect sense
03:10defncant believe i missed that
03:10defnthanks
03:11Licenser_;P
03:11Licenser_well I got to go take care defn
03:11defnLicenser_: i owe you. thanks again
03:12Licenser_nah it's all in a days work :P
03:15remleduffdefn: Not sure if you solved it another way, but you can also (binding [*read-eval* false] (read-string "#=(println \"Don't print me\")))
03:15defnremleduff: I think Licenser_'s solution is better. I shouldn't really be touching any of the results with read-string in the first place
03:15defnbut thanks for that
05:20gerryxiaohow to get current classloader?
05:26hoeckgerryxiao: pick one: http://java.sun.com/javase/7/docs/api/java/lang/class-use/ClassLoader.html
05:26sexpbot"Uses of Class java.lang.ClassLoader (Java Platform SE 7 b66)"
05:27hoeckgerryxiao: eg. (ClassLoader/getSystemClassLoader)
05:27Blktis there anyone who succesfully used clojure.contrib.sql?
05:27hoeckor (.getClassLoader (class {}))
05:28hoeckBlkt: yes, though I don't really like it
05:29Blkthoeck: me neither, though I have to ask you something about tables creation
05:29hoeckBlkt: oh, havent used that part of contrib sql
05:29sids,(clojure.lang.RT/baseLoader)
05:29clojurebot#<DynamicClassLoader clojure.lang.DynamicClassLoader@3a8eac>
05:30Blkthoeck: haven't you ever created a table with contrib sql?
05:31hoeckBlkt: only with plain strings, send over to the database with c.c.sql/do-commands
05:32Blkthoeck: you normally used c.c.sql/insert-values or insert-rows function to add rows after that or you used strings as before??
05:33hoeckright, plain strings
05:33Blktthanks for the help, I think I'll do it that way too
05:34hoeckI am to lazy to mess around with that part of c.c.sql, what I especially like is the abstraction c.c.sql provides about connecting to a db
06:01LauJensenHi guys
06:09AWizzArdHello the Lau.
06:16kzarSo when I noticed my frame's timer was still running after I closed the window I tried adding (.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE).. That kind of worked except it totally killed my Java process, how can I make it behave properly?
06:18LauJensenkzar: I didn't catch the preceeding discussion, but sounds like you need to override onclose
06:19LauJensenhttp://github.com/LauJensen/Fluid-Dynamics/blob/master/fluids.clj#L294
06:22patrkris#'x and (var x) is equivalent, right?
06:22patrkris*are
06:26kzarLauJensen: So say if my timer ends up making my move-ball function run every few seconds, if I check for running at the top of my move-ball function it kind of works. But surely I should stop the timer from trying to run all my code? I should get rid of the cause?
06:27LauJensenkzar: Is the code public somewhere?
06:27LauJensen(afk 5 min)
06:27kzarLauJensen: no not yet I'm just throwing it all together at the mo
06:34LauJensenIm trying to understand your question. You've put a (when @running) in your move-ball, but instead you want it in your timer (where it should be), but thats giving you a problem ?
06:35kzarLauJensen: I put the (when @running in the actionPerformed section of my panel
06:35kzarLauJensen: Then when I close the Frame it does stop my stuff getting run, but then when I set running back to true it's all going still
06:36LauJensenSounds like you need to put your predicate in another place, ping us again when the code is up somewhere
06:37kzarLauJensen: OK I'll paste it but it's really bad atm
06:38kzarLauJensen: http://paste.lisp.org/display/98709
06:40LauJensenOk, and what exactly is running when you reset! running true after having closed, and what do you want to happen instead?
06:41jowagis it ok to put lazy seqs inside refs, or I have to realize the seq before putting it into the ref?
06:41LauJensen$(ref (range 10))
06:41sexpbotresult: clojure.lang.Ref@8cc09a
06:41jowage.g. (alter *x* (fn [coll] (remove pred coll)))
06:42Chousukejowag: it's okay as long as the seq has no side-effects
06:43jowagthank you
06:46kzarLauJensen: Well move has a println that I can watch from *inferior-lisp*. It does stop when I close the window but when I (reset! running true) it starts printing again
06:46LauJensenkzar: As it should - All you're stopping is the ActionPerformed listener, that doesn't stop the mouseMoved event if you trigger that
06:47LauJensenIf the program is to die once you close it, set JFRAME/EXIT_ON_CLOSE instead
06:47LauJensenThe shared @running ref is helpful to stop independant thread workers, but swing will bring its own house down once you EXIT from it
06:49kzarLauJensen: But here's the thing that concerns me, supposing I'm making this little game and I make a change. I close the window and run (game) again. Now there's two of these processes running, maybe my ball will start moving twice as fast? Also maybe my computer will slow down if there are all these things running in the background?
06:49kzarLauJensen: I tried EXIT_ON_CLOSE before but it then killed Java and I had to re-start slime every time I closed the window
06:50LauJensenRight now, you're starting a swing app, a game but you're never destroy it (ie clean all the resources), which is a bug because you're carrying state. To clean that up, you need EXIT_ON_CLOSE and yes that does bring the repl down with it - I dont know if there's a work-around for that though
06:51eevar2kzar: ideally you'd calculate your ball position/movement based on the current time
06:51LauJenseneevar2: he's using user-input I believe
06:52kzarno it's all broken and not written yet
06:52kzarthat's why I didn't want to paste it but yea you're right about the movement thing
06:52eevar2well, using the clock rather than updating it per frame or something like that
06:55eevar2kzar: but what's the issue? -- @running not getting set when you close the window?
06:55kzareevar2: No that part works
06:58kzarLauJensen: Thanks for showing me the @running thing anyway
06:58LauJensennp
07:00eevar2could also do something like (if (.isVisible frame) (recur)))))) in your drawing loop -- assuming you use immediate mode rendering
07:01eevar2s/loop/thread
07:01LauJensen(future (while (.isVisible frame))) might be better, but its patch-work
07:11jowagI have a struct (defstruct s :a :b :c) and a existing map (def m {:a 1 :b 2}). How do I create struct from this map? (struct-map s m) is obviously not working
07:14jowagalso (apply struct-map s m) is not doing it right
07:15cgrandkzar: you don't need @running in you current design, you simply need to call .stop on timer in windowClosing
07:26jowagok, found it (apply struct-map s (flatten (seq m))) will do the trick
07:29BorkdudeC-x b to switch buffer, C-x k <RET> to close a window -- in an internet borwser and then find out it doesn't work. What is this called?
07:29Borkdudes/borwser/browser
07:30hircustechnomancy|away: ping
07:35LauJensenBorkdude: The disappointment of your life - same here :)
07:36Fossii heard opera supports emacs keybindings at least rudimentary
07:37Fossiusing nano and constantly pressing ctrl+w to search is more annoying though
07:40eevar2ctrl+w sucks in netbeans as well. in most tabbed apps, actually
07:43_atoBorkdude: it's called "you should be using conkeror"
07:43_atohttp://conkeror.org/
07:43sexpbot"FrontPage - Conkeror"
07:51Borkdude_ato tnx, I installed it now. Does it to URL autocompletion? ;)
07:51Borkdudes/to/do
07:52_atoyeah.. I think you have to turn it on though, just a sec while I find it
07:54_atourl_completion_use_history = true;
07:54BorkdudeIs there a .emacs like thing in this browser?
07:54_ato~/.conkerorrc
07:54clojurebotI don't understand.
07:54Chousukea:P
07:54Chousuke-a
07:55Borkdudetnx
07:58Borkdude_ato: do you have next/previous in this browser? can't find it in the tutorial
07:59_ato'B' (shift b) is back, 'F' is forward
08:00_atoif you have a page with "Next" and "Prev" links (like a comic or reddit or something) use [ [ and ] ] (one of my favourite features, very simple but a real time saver)
08:01mmarczykConkeror! it's been ages since I used that :-)
08:01mmarczykit's been a tad immature back then, gotta give it another go :-)
08:01_atoC-h b will give you a list of keybindings
08:02BorkdudeI tried it with a couple of sites, everything seems to work OK until now
08:04Borkdudeah like XKCD, that's nice
08:06LauJensen?
08:10Borkdude_ato: if I see a couple of links on a wikipedia page, what is the handiest thing to do when I want to open one in a new buffer?
08:11mmarczykC-u f
08:12Borkdudecool, tnx
08:12LauJensenwow, thats great
08:12mmarczykyeah, it is :-D
08:13BorkdudeNot to be confused with Konqueror
08:13LauJensenThis has got to be the best news all day - an Emacs browser :)
08:13LauJensenIs there any way to embed it directly in emacs ?
08:14BorkdudeLauJensen, yes, there is swank-conkeror... so parse the html directly with slime :P
08:15_atotheoretically yes, but there's not a huge amount of benefit to doing so given one speaks javascript and the elisp http://www.emacswiki.org/emacs/EmacsXembed
08:15sexpbot"EmacsWiki: Emacs Xembed"
08:15_atothere's actually an inferior javascript thing for emacs that will talk to conkeror
08:15_atokind of like slime
08:15_atodoesn't work perfectly though
08:17_atoI just have a global keybinding which switches focus to the browser and another which switches focus to emacs (and a third which switches to the shell).
08:17LauJensen_ato: not following? I just meant C-x C-f in Emacs should allow you to browse to an url, and then it was actually conkeror doing the work
08:17_atoah
08:17_atoyep
08:17_atowell
08:17_atomaybe not C-x C-f
08:17LauJensen_ato: How did u bind it to switch to C?
08:17_atobut there's a way to enable links to open in it
08:17LauJensenyea
08:17LauJensenbrowse-url
08:19_ato(setq browse-url-browser-function 'browse-url-generic browse-url-generic-program "conkeror")
08:19_atoI suppose
08:20BorkdudeI recently changed it to chromium-browser, but that might change soon
08:21LauJensen_ato: Know of a shortcut to moving the cursor to flash
08:21LauJensen?
08:21_atoheh, I'm actually using chromium at the moment, I switch back and forth between conkeror and chromium every now and then. Get sick of chromium's crap keyboard support and then get sick of Conkeror's gecko rendering being slow and memory hog
08:21_atoI really want conkeror with chromium rendering
08:22_atoand clojure scripting :p
08:22Borkdude_ato, can you give answer on how you switch to Conkeror with a key-binding?
08:22Borkdudeand back from Conkeror to Emacs
08:22_atoLauJensen: nope I never found a good solution to flash, flash is one of the annoying things in conkeror
08:22LauJensen(.replaceAll "in conkeror" "")
08:23_atoBorkdude: I use the Sawfish window manager
08:23Borkdudeah, so it isn't an Emacs key-binding but a wm keybinding
08:24mmarczyk_ato: I almost believed you've decribed an actual perfect browser for a sec
08:24mmarczykas it is, I share your dream...
08:24Borkdudeyes, _ato... I do to, but then Emacs with Clojure scripting is also part of that dream?
08:26_atoso with sawfish I have this in config, which I probably just stole from _mst's sawfish config: http://gist.github.com/388039
08:26mmarczykit would have been cool if the Guile people had rewritten Emacs, like, 15 years ago -- we'd all have settled into a nice Scheme-based editor by now :-(
08:26_atoand the same for terminal, browser etc
08:27_atoI started writing a Clojure browser with QT Jambi actually
08:27_atobut QT Jambi's webkit version is old, and it's slow :(
08:28_atoand QT Jambi is no longer supported by Trolltech so it's kind of a dead end that way too
08:28LauJensen_ato: Unless you find a sponsor :)
08:28LauJensenIt was sooooo close to _really_ good
08:28defnany suggestions on making it more obvious that you can click on an example to see it's result? http://getclojure.org:8080/examples/concat
08:28sexpbot"concat"
08:29Raynessexpbot: I appreciate the stating of the obvious there.
08:29defnI've added some CSS to give you a different cursor when you mousover, but not all browsers play nice.
08:30mmarczykdefn: how about adding a notice at the top saying "you can click on an example to see its result"? :-)
08:30defnmmarczyk: hehe, yes but that's so...ugly :)
08:30mmarczyknice page, btw
08:30defnmmarczyk: you can do /examples/anyfunction to see examples of that function
08:31RaynesSo is people doing "This stuff sucks" and then 30 days later, accidentally clicking on an example and being like "Who was the idiot who designed this page?"
08:31_atoI guess you need some sort of arrowy-expandy button thingy
08:31mmarczyk2. (class (concat 1 2)) ?
08:31defnyeah _ato i was thinking something along those lines maybe
08:31mmarczykthat's broken :-)
08:31defn,(class (concat 1 2))
08:31clojurebotclojure.lang.LazySeq
08:31defnno it's not :)
08:31_atoor alterntively just always show the result :p
08:31chouserdefn: a link to the left of the bottom of each snippet (under the number)?
08:32mmarczyk,(concat 1 2)
08:32clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer
08:32Raynes$(class (concat 1 2))
08:32sexpbotresult: class clojure.lang.LazySeq
08:32zmiladefn, add attribute title='click the example text to evaluate and see the result' to the enclosing <div>
08:32defnchouser: a la the labrepl -- yeah i think that's a good way to go
08:32LauJensenRaynes: I got a message via your bot the other day, saying that the s/x/y feature was implemented, subsequently I tried it out and it FAILED
08:32mmarczykit's lazy, so won't break immediately, but it would help to use fully working examples
08:32mmarczyk$s/FAILED/SUCCEEDED/
08:32sexpbotCommand not found. No entiendo lo que estás diciendo.
08:33mmarczykindeed
08:33RaynesHaha.
08:33Rayness/indeed/omg/
08:33sexpbotHaha.
08:33mmarczykdefn: except of course where it's supposed to break
08:33defnmmarczyk: eventually, someday, way way in the future, in a different world, i hope to add the ability to actually vote up or vote down an example
08:33RaynesLauJensen: How did it fail, exactly?
08:33mmarczykdefn: you could move the numbers to the left of the code boxes
08:33LauJensenin the way that it didn't react
08:33LauJensen_ato: Where's adblock activated in conkeror?
08:33RaynesLauJensen: Well, as you can see, it works now. :)
08:34Rayness/Well/indeed/
08:34sexpbotLauJensen: indeed, as you can see, it works now. :)
08:34mmarczykdefn: and display the "click for result" notice below the HR in a nice subdued grey
08:34Borkdudedefn: can users contribute their examples?
08:34defnmmarczyk: cool advice
08:34LauJensens/adblock/adjure/
08:34sexpbotmmarczyk: cool advice
08:34_atoLauJensen: once you've installed M-x adblockplus-settings
08:34defnBorkdude: (this (is (an (example)))) <---submitted
08:34mmarczykLauJensen: apparently you've just caught a sexpbot bug :-)
08:34defnit wont run in the sandbox of course, but it will be submitted
08:35RaynesLauJensen: I guess Erik didn't make that little special case user-based. I'll ask him to do it or do it myself later.
08:35mmarczykdefn: how about putting a bot here, on #clojure, to accept examples
08:35Borkdudedefn: it reads examples from #clojure? where I can see the example you just told me?
08:35defnmmarczyk: already in progress
08:35mmarczykdefn: which we could submit as interesting stuff comes up in conversations :-)
08:35Raynesmmarczyk: Already in progress, and it uses Irclj. ;)
08:35mmarczykdefn: oh, great :-)
08:35mmarczykcool!
08:35_ato,(concat "hello" "_ato")
08:35clojurebot(\h \e \l \l \o \_ \a \t \o)
08:36Raynesdefn: If it's really important, I'll get some logging into Irclj quickly. I've been putting it off.
08:36defn_ato: right now i dont have the continuous update thing running on my server, but it will work very soon
08:36_atocool
08:36defnRaynes: not really important, in fact i think I can do pretty much everything i need with what currently exists without the logging functionality
08:37RaynesI think that defn running a walton-bot would be better than sexpbot running it. At least, unless it suddenly stops taking a month to parse logs. :p
08:37defnbasically :on-message (add-sexp-to-ref (hunt-for-sexp message))
08:37defnthen every hour or so use stupiddb to serialize it
08:37zmiladefn, why such order of examples? mix of simple ones and complicated. can you sort them?
08:37Raynessexpbot has a walton plugin, but I keep it disabled because it tends to screw stuff up.
08:38defnzmila: also a feature id really love to add, but there have been some...shall i say...hiccups -- it's definitely the plan to have filtering functionality though
08:39defnalso, as long as i have everyone's attention: http://github.com/defn/walton "patches welcome"
08:39_atoheh, could use that golf scoring scheme somebody came up with on the mailing list, symbol counts and such to score complexity and then sort by that, so the examples get progressively more complex
08:39defnsee the wiki for stuff on the todo list
08:39defn_ato: ooo! link!
08:40defnim not a golfer, but incremental complexity scoring thingamajig sounds cool :)
08:40Borkdudedefn: a voting mechanism a la stackoverflow would be really cool
08:40defnBorkdude: you're seeing the forest now! that's exactly what i intend to build
08:40_atogoogle groups search is so crap... hmm
08:40defnsomething a lot like stackoverflow
08:40defnonly more code-specific
08:41chouserhttp://groups.google.com/group/clojure/browse_thread/thread/c3bbffe417fc6fcb/bf5d1ff5a943c295
08:41defnid like to spin off the code and allow people to write parsers for other languages and build a python, ruby, etc. version of the site
08:41Borkdudedefn: how do you filter our crap examples, or erroneous ones like when somebody asks a question and first proposed faulty code?
08:42Borkdudes/our/out
08:42defnBorkdude: i use Licenser and Rayne's work -- the clj-sandbox
08:42defnit runs code in a sandbox and if they run, that's what you see
08:42bsteuberhm, I still can't get swank-clojure to work with the new meta syntax - is there something eval'ed that doesn't come from swank-clojure itself, like clojure-mode etc.?
08:43Borkdudeso if it runs, it gets read into the site?
08:43defnyeah, not continuously yet, but it gets updated with new logs every couple days
08:43BorkdudeI see. Good luck with that, it's very cool imho
08:43defnso: (first [1 2 3 4]) will show up on there if it's not a duplicate
08:43defnjust for me having written it here
08:44chouserdefn: I think this may be the "final" implementation: http://groups.google.com/group/clojure/msg/bae1846d558ad038
08:44defnchouser: awesome. thanks
08:45wlangstrothdefn: are we discussing walton?
08:45defnwlangstroth: indeed
08:45wlangstrothI've used it a bunch - I love the new look
08:45defnwlangstroth: thanks man. my friend did that for me. he's working on a front page
08:47wlangstrothdefn: is there a way to force it towards certain results? For instance, when I do http://getclojure.org:8080/examples/for it gives me for *and* format
08:47sexpbot"for"
08:47wlangstrothany way around that?
08:48defnit can be quite fun when someone asks, "how do i reverse a map {:a 3 :b 4} and sorts by value" or something like that, or a question about destructuing -- doing /examples/let is pretty interesting to see how powerful destructuring can be
08:48defnwlangstroth: im working on some filtering that will let you be specific to symbols instead of strings
08:48wlangstrothnice
08:49defnwlangstroth: really glad you like it :)
08:50defnwlangstroth: submit a feature suggestion via github issues if you have the time
08:50defnit keeps things visible for me -- lots of ideas on functionality, but only so much time and all that
08:51wlangstrothokay, np
08:54Borkdudeone paredit question: if I have (foo "bar" "baz"|) how do I swap "bar" and "baz"?
08:55mmarczykC-M-t between "bar" and "baz"
08:56defntest
08:57Borkdudetnx.., although Gnome opens a terminal window for me now, have to fix that ;)
08:57_atodefn: have you heard of the squeak (smalltalk) method finder?
08:57wlangstrothIs anyone clear on why there's a next and rest? I was under the impression that ISeq was always meant to return nil if empty (like next does). Is rest a special exception to that?
08:58Chousukewlangstroth: rest is the norm
08:58defn_ato: i havent
08:58mmarczykwlangstroth: that used to be true, but hasn't been for a long time now
08:58wlangstrothmmarczyk: okay, that's what I figured it was - thanks
08:58_atodefn: someone mentioned that here before (or on the list) and it's a really cool idea that you might like for walton as well... basically..
08:59_atodefn: it's for finding a function when you don't know it's name. You give it some arguments and an expected result and it gives you back a function name
08:59_atoso you'd enter: 2 3 => 5
08:59_atoand it'd reply: (+ 2 3) => 5
09:00_atopresumably you could implement it by just brute-force trying a big list of pure functions
09:00_atoand try it with the arguments reordered too, as the user may not know the right order for them
09:00defn_ato: i started working on something like that actually
09:00defncalled whatfn -- i havent really touched it, but it's inspired by _why's "what_method?"
09:00defn(what? [1 2 3] [3 2 1])
09:01defn=> (reverse [1 2 3])
09:01defnyour version seems like it might be easier
09:02defnit'd be cool to say (what? ["a" "b" "c"] ["B" "C" "A"])
09:02Raynesdefn: I can work with that.
09:02_atohaha, I looked at your github and it's like: usage: (what? ...) and I think awesome! he's already done it
09:02_atohttp://github.com/defn/whatfn/blob/master/src/whatfn/core.clj
09:02_atobut the clj was bare :(
09:02Raynesdefn: Isn't his version the exact same "easy" version I proposed when we were talking about it the other night? ;)
09:03_ato;-)
09:03defnRaynes: _ato haha i became a bit obsessed with making it better and better before i even started
09:03defni want it to chain functions and do all sorts of crazy inference engine AI type stuff
09:03defnbut your version is so much more doable
09:04mmarczyk...then at some point you could say (what? --a-huge-number--) and get back (nth-mersenne-prime 53) ;-)
09:04_atohaha
09:04defn:)
09:04defnit'd be filled with easter eggs, for sure
09:04defnsee: wolfram alpha :)
09:04wlangstrothThe idea of making a function look-up the most powerful tool in the universe is hilarious.
09:06defnwolfram alpha: please promise to solve all my problems and then do a mediocre job across the board
09:07BorkdudeTwitter is the Wolfram Alpha for questions that do not have numerical answers
09:07wlangstrothThey really missed the boat on some funny UI features. For instance, with anything the search can't answer, it should return "Thinking ..." or "Processing ..."
09:07wlangstroth(and never actually answer the question)
09:07defnwlangstroth: hahaha -- that'd be great
09:08wlangstrothPeople would likely figure that it was thinking REALLY hard, or that they broke it.
09:08Borkdudewlangstroth: it would be great if it could decide whether the problem is indecidable or not
09:08wlangstrothBorkdude: you mean for things like unsolvable differential equations?
09:08defn"I'm stuck. Sent email to Stephen Hawking..."
09:09defn"You've heard of Fermat's last theorem, right?"
09:09defnan infinite number of fun responses :)
09:09wlangstrothdefn: I like "currently on the phone with Stephen Hawking". Imagine how that conversation would sound.
09:09defnwlangstroth: brilliant. :)
09:10defn"Using second life line."
09:10wlangstrothhaha
09:10wlangstroth(what? "life")
09:10defn=> 42
09:10wlangstroth=> "Contacting Richard Dawkins and the Dalai Lama"
09:11defnhahahahaha
09:11defn=> "Daniel Dennett may know this one! Seriously!"
09:11wlangstrothThat would be for (what? "consciousness")
09:11Borkdude"Have you thought about this yourself already?"
09:11Borkdude"RTFM"
09:12wlangstroth"Please hold ... accessing Daniel Dennett"
09:12defn=> "Contacting Christopher Hitchens for a pithy response..."
09:12Borkdude"Gathering responses from Twitter..."
09:12defnactually, what would be great is if it can't answer the quesiton, it just gets a completely random twitter message about Justin Bieber
09:13defni think that'd really send the whole thing home
09:13wlangstrothhaha
09:13defnOr how about this: it presents a dialog: "Is this your IP?" [Yes/No]
09:13defn"Stay where you are."
09:13wlangstrothI haven't even seen this Bieber kid, but someone told me he's causing teenage girls to trample each other
09:14defnit's a bit of pop culture I'm not so happy to admit I'm aware of
09:14defnmy little brother tweets exclusively about his hatred for the boy -- more important things to be chatting about i say, but to each his own
09:16wlangstrothtrue nuff. Here's another open-ended question: would I be stepping on anybody's toes if I wrote more detailed documentation for clojure core?
09:17defnwlangstroth: i don't think so.. i mean i look at it like this: even if you are duplicating effort, it's a fantastic way to learn more for yourself, and provide content for others
09:17defni say have a go at it
09:18Borkdudedefn, it would be great to combine the most useful (upvoted...) examples into the clojure documentation
09:18wlangstrothI'm already doing it to learn, but I guess we'll see if anyone's into it once I've finished
09:19defnBorkdude: maybe at some point that could happen, but that'd largely be at rich and others' request/authorization
09:19wlangstrothBorkdude: the examples are exactly what I was thinking about. Take the example for "for":
09:19wlangstroth,(doc for)
09:19clojurebot"([seq-exprs body-expr]); List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero or more modifiers, and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost fastest, and nested coll-exprs can refer to bindings created in prior binding-forms. Supported modifiers are: :let [binding-form expr ...], :while test, :when test. (
09:20defnyeah...oof...
09:20Borkdudedefn: wlangstroth: maybe you can have a contrib like approach to the documentation, when it will be used enough it can end up in the official documentation at some point?
09:20defni mean maybe im a simpleton, but that text just does not immediately say to me: "here's how you use 'for'", which ought to be the aim of such a docstring
09:21Borkdudedefn: amen
09:21wlangstrothWe'll try that. I don't think Rich has my CA yet. I only mailed it a couple of weeks ago, though.
09:21defni suppose one problem is that docstrings are not meant to be so long-winded
09:21defnit might be nice to have a bit of meta that points to a good example
09:21Blkthello everyone
09:21Borkdudedefn: wlangstroth: I also miss "also see ..." in the docs
09:21wlangstrothdefn: exactly - I'm not suggesting a replacement (except for "for", maybe, because that one completely confused me as a beginner)
09:22_atoheh
09:22defnyeah, same here -- im still a bit iffy on using it
09:22_atoit chopped off the useful part of that docstring:
09:22defnim pretty much a beginner though
09:22_ato(take 100 (for [x (range 100000000) y (range 1000000) :while (< y x)] [x y]))
09:22wlangstrothBorkdude: that's a bit tougher to do, though, and I think it's just Tom who's working on the docs, so his hands are full
09:23defnthe thing with clojure is than 6/10 times viewing the actual source is more helpful than the docstring
09:23defnthe docstring itself is a very well thought out version of the reasoning that exists in the code
09:23defnand once you see the code you say "ahhhh!"
09:23Borkdudedefn: how can I view the source in emacs btw?
09:23defnbut for people not familiar with FP it is very weird at first
09:23defnBorkdude: do you use slime?
09:23Borkdudedefn: yes
09:24chouseryeah, I use 'source' about as much as I do 'doc' for most things
09:24chousernot including gen-class
09:24defnput your pointer at (foo|)
09:24defnand hit M-.
09:24defn(zipmap|) for instance
09:24defnwhere the | is your pointer
09:24defnhit M-, to get back to your repl
09:25Borkdudedefn: no context for finding locations.
09:25BorkdudeI guess I have to use the clojure-src.jar or smth?
09:25defnhmm, weird
09:25defnim just using M-x slime with all of the ELPA packages, slime-repl, slime, clojure-mode, swank-clojure
09:25Borkdudedefn sorry I dit C-M-.
09:25Borkdudedid
09:25Borkdudeit works
09:26defncool -- that's insanely helpful
09:26defnit should be one of the first things people learn once they're up and running with a slime repl
09:26rhickeywant serializable data structures in 1.2? Move this patch forward now: https://www.assembla.com/spaces/clojure/tickets/281-make-more-datastructures-serializable
09:26defntook me a month or two :X
09:26sexpbot"#281 - Make more datastructures serializable (Test) | Clojure | Assembla"
09:27peregrine81unless you use Vim!
09:28defnvim and emacs will i think eventually fall out of favor when IDE support really gets rolling. there are a lot of fantastic projects that exist right now, but i think it's still an argument as to whether they beat emacs + slime + paredit yet
09:29defna nice refactoring browser would squash anything vim or emacs has to offer
09:29Borkdudedefn: which IDE support is the best up till now you think?
09:29peregrine81defn: agreed but many people still use emacs or vi for every day programming.
09:29defnBorkdude: i dont know enough, but i thought enclojure was quite good
09:29LauJensendefn: You're wrong and speaking out of ignorance
09:29peregrine81Counterclockwise was very good.
09:29zmilathere is no argument for those who has 6+ years using Eclipse, but only two or three times runned emacs
09:30Borkdudedefn: I started ClojureBox in the beginning, but I had some classpath problems
09:30wlangstrothLauJensen: you always enter with a bang, I'll give you that
09:30Borkdudedefn: then I started using Eclipse + CounterClockwise, but the obliged paredit made me feel sick, because I didn't know that yet
09:30LauJensenNot meant harshly mind you :)
09:30BorkdudeSo then I switched to emacs, using elpa swank clojure, and it's the best I've used so far
09:31wlangstrothLauJensen: I think everyone is familiar with your love of emacs
09:31defnLauJensen: maybe-- i won't try and act like i know everything about emacs, vim, enclojure, etc. I was swayed by Uncle Bob's comments on Smalltalk, refactoring browsers, etc.
09:32BorkdudeLauJensen, do you do Java development in Emacs, without any other IDE?
09:32defnJDE is pretty good for emacs
09:33LauJensendefn: Emacs big win is integration. You have fantastic editing tools, which makes you so much faster than the guys sitting in these big IDEs, you have IRC, Gist, Git, SVN, Hg integration at your fingertips, testing is built in, organizing/planning is built in - You can start Emacs in the morning and not close it till you release, because literally everything is in there - the payoff is effectiveness like you wouldn't believe
09:33defnfamiliarity will always play a role. i don't know. I love emacs and have no good reason to switch, but I have faith that the proper combination of features could make me switch.
09:34defnLauJensen: yeah but one thing i love one moment and hate the next with emacs: choice
09:34defnthere are too many damned choices. it's distracting
09:34LauJensenhuh?
09:34defni spent 8% of my time in emacs configuring emacs
09:34LauJensenOdd, I spend like 0.01% :)
09:34Borkdudedefn: I was thinking how touch screens would change the need of remembering key combinations for paredit. It's much more intuitive to just select some sexp elements and move them around with your finger maybe?
09:35defnLauJensen: im just suggesting that choice can sometimes be a problem. it's something i value in emacs one minute, and find distracting the next.
09:35RaynesSpeaking of Git, is there a way to make Magit pull from a different repository than the default one? Like, you can change where it pushes with a prefix argument.
09:35LauJensendefn: Sure I understand. Like comparing Ubuntu to Arch. Arch takes a lot longer to set up initially, but once you have a working config, its trail blazing
09:35licoresse defn: I agree, (choice)
09:36defnLauJensen: but im never finished setting up emacs. there's always one more tweak, one more hotkey i think of, one more function i should write.
09:36defnsometimes i dont want to know how much power i have
09:36LauJensenhehe
09:36defnLauJensen: that being said i am 100% happy with emacs and wouldn't switch for all the tea in china, as they say
09:37LauJensenAll I can say is, that its not been a problem for me, but then maybe Emacs isn't for everybody. I just dont think it's going to be blown out of the water anytime soon
09:37wlangstrothvim and emacs are like different languages: are we going to argue about whether English or German is a "better" language?
09:37LauJensendefn: And me on the other hand, I would switch for all the tea in china :)
09:37defnLauJensen: yeah i will agree, not blown out of the water, but you just..nefver..know.. :)
09:37defnLauJensen: haha
09:37LauJensenwlangstroth: no, German is clearly better
09:38defnwlangstroth: i dont think there was ever a vim/emacs duel going on here
09:38defnit's what works for you
09:38wlangstrothhaha
09:38BorkdudeWhy would you need vi when you have a vi mode for Emacs? ;)
09:38wlangstrothso is there actually a large demand for serialized data structures in clojure?
09:39wlangstrothI didn't see anyone jumping when Rich posted that
09:39BorkdudeLauJensen: do you use Arch btw?
09:40defnwlangstroth: it'd be nice. im using them now. since refs are db-like in their concurrency semantics I find the idea of serializing structures quite appealing.
09:41defnas i understand it you can serialize structures earlier than 1.2 but maybe im misunderstanding something
09:43LauJensenBorkdude: Yes its installed, although Ubuntu is my main OS atm until I get my partitions sortedo ut
09:43wlangstrothdefn: I'm having difficulty seeing the added value, but I might be misunderstanding Java serialization.
09:46_atoI think it might be useful for some of those distributed computing libraries
09:46_atosending objects across the network seamlessly etc
09:47_atoI don't know enough about java's serialization to be able to fix that patch
09:48_atoif it just needs reformatting then no problem, it applies cleanly for me
09:49wlangstroth_ato: the first diff to the patch just added "Serializable" to each of the data structures, I think (which is all you're supposed to do in Java, but clojure already has the immutable structures ... I'll obviously have to research this more)
09:53wlangstroth_ato: do you mean other concurrency libraries in Java?
09:53cemerickrhickey: regarding 281 (serialization) -- by "moving it forward", do you mean making the patch apply, or are there any outstanding technical issue?
09:53cemerickissues*
09:55rhickeycemerick: whichever. I'm not sure what Brian meant by this: http://groups.google.com/group/clojure/msg/e8a9c7392bd82fd6
09:58cemerickrhickey: From his comments on the ticket, it sounds like he was concerned about transients. Either way, shouldn't be too difficult to skin that cat so that reasonable things happen (e.g. throw an exception when attempting to serialize a transient, or maybe (probably not) cons up a persistent copy, and serialize that).
09:59rhickeycemerick: transients are non-serializable, please
09:59cemericksure
10:00cemerickrhickey: I can claim that issue, if Brian's not going to get it in in time. Is there a window you have in mind for the RC?
10:00rhickeycemerick: great! ASAP
10:01rhickeycemerick: If he was worrying about encountering an inner node that was under modification by a transient while traversing from a persistent root- that can't happen. And since the transient roots are different type, making them non-Serializable is sufficient
10:03cemerickrhickey: OK; in any case, I'll be adding a metric ton of tests to ensure that the right things happen. This is one of those things that, if a regression slips through, one doesn't find out about it until the regression is bound to cause serious problems.
10:04rhickeycemerick: It would be great to see this in 1.2, and in the hands of an interested party :)
10:11AWizzArdAre there plans to have deftype/defrecord produce no constructor, so that users will be forced to use my provided factory fn?
10:12chouserAWizzArd: how would your factory fn be written if there were not constructor?
10:14chouserRaynes: just turn them off
10:14Rayneschouser: I can't. I've tried in a thousand different ways.
10:14RaynesI guess a library or something that I require is turning them on.
10:14chouser:-(
10:15RaynesI can set it with binding, set!, anything. They still show. :|
10:15defnahh, that's mean of them
10:15chouserhave you tried using set! immediately after 'require'ing all your libs?
10:15RaynesNo, I didn't try that. I assumed that it was happening when the libs were required.
10:16chouseryeah, it may be
10:16RaynesAs soon as they are required, around 30 reflection warnings fly my way.
10:16chouserI'm very sorry. sounds horrible.
10:16RaynesI'm tempted to hunt down which library is doing it and then beg for them to shut it off.
10:17defnRaynes: is this in irclj?
10:17defnill hunt down the bandit :)
10:17Rayneshttp://gist.github.com/388130
10:17Raynesdefn: No, it's in sexpbot.
10:18RaynesThat's more than 30.
10:18Raynes:o
10:18defnRaynes: just open a new repl and (use '...) each of them one by one
10:18RaynesGood idea.
10:18RaynesI'll do that in a moment.
10:20_atoor: mkdir /tmp/blah; cd /tmp/blah; for lib in ~/src/sexpbot/lib/*.jar; do unzip $lib; done; grep -R 'warn-on-reflection' .
10:20hiredmanpfft
10:20RaynesFound it.
10:20Raynesclj-apache-http
10:20RaynesBad news, man.
10:20hiredmanuse finf
10:20hiredmanuse find
10:21_atohiredman: find inside jars? or you mean find to filter to clj files before grepping?
10:21AWizzArdchouser: the factory could be inside the defrecord form
10:22AWizzArdSo the defrecord could produce a private constructor or something like that.
10:22chouserAWizzArd: ah, I see. I haven't heard of any plans like that.
10:22_atohttp://meshy.org/~ato/clojure-group-stats/
10:22sexpbot"Clojure group subscriber count graph"
10:22_atoseems it gains 4 or 5 subscribers a day
10:23AWizzArdchouser: this could potentially be a protection from data corruption.
10:33RaynesFor great justice! I've done it! No more reflection warnings.
10:39BorkdudeAh, the kill-other-buffers in Conkeror is really what I need
10:41LauJensenBorkdude: hotkey ?
10:41Borkdudedunno, I just do M-x
10:41cemerickrhickey: are you aware of the prependss type in core.clj?
10:41LauJensenBorkdude: its not bound by default I see
10:41BorkdudeM-x k tab o tab <RET>
10:43Borkdudeone more thing I need to find out is how to give the focus back to the window, so it listens to "g", "c" etc, when I am in GTalk inside Gmail
10:43Borkdudewithout using the mouse that is
10:46Borkdudeah, escape
10:46Borkdudedamn this browser is cool ;)
10:50LauJensenits super fantastic incredible and outstanding
10:57RaynesWhoa whoa whoa! Who uses GTalk? ;o
10:57BorkdudeRaynes: I do, smth wrong? :)
10:58RaynesTotally not. I just didn't realize people actually used that.
10:58Raynes:o
11:00BorkdudeRaynes: what do you use
11:00RaynesI use IRC.
11:00Raynes:p
11:00BorkdudeMe 2 ;)
11:00defnI use gtalk, irc, aim -- pidgin makes the whole maze of chat networks pretty manageable
11:00defnbut irc for all "srs bsns" of course
11:00RaynesI use pidgin for MSN.
11:01RaynesBut I haven't been using it recently, because all the interesting people are here or in #clojure-casual.
11:07LauJensenif I could, I would use Conkeror for everything :)
11:12rhickeycemerick: what about prependss ?
11:14cemerickrhickey: I figured it was a typo?
11:15rhickeyss = symbol/seq
11:15rhickeyjust an internal fn Steve used for load stuff
11:15wthiddenQ: what is the difference between load-file and load-reader?
11:18cemerickrhickey: FYI, the existing patches on 281 are not comprehensive.
11:18rhickeycemerick: ok
11:19rhickeywhat's missing?
11:20bhunjiI love Lisp, is there love in Clojure?
11:20RaynesWe're all like a bunch of hippies in here.
11:21cemerickrhickey: PAMap and PQueue so far.
11:21bhunjiRaynes: thats good loving mon
11:21cemerickrhickey: Any objections to putting Serializable on the abstract classes, as opposed to scatting it across all the concrete impls?
11:21cemerickscattering*
11:22rhickeycemerick: any drawbacks?
11:24cemerickrhickey: Not that I can tell. Maybe the false implication that any derivee will get serialization for free, when they'd probably have inner classes they'd still have to mark appropriately.
11:24cemerickThird parties should mostly be using the interfaces, anyway.
11:24rhickeycemerick: you'd just need to audit that all derivees in Clojure itself are in fact serializable
11:27cemerickrhickey: I'll root around. Aside from transients (which appear to have their own class hierarchy anyway), any other candidates for exclusion off the top of your head?
11:28rhickeycemerick: exclusion via what mechanism? one problem with Serializable as a mixin tag interface is you can't get rid of it
11:29cemerickrhickey: If the vast majority of derivees are rightly serializable, the outliers can add a writeObject method that throws an exception.
11:29rhickeycemerick: sounds icky, is that convention?
11:30cemerickrhickey: it would be icky. That's definitely the easiest route.
11:31rhickeycemerick: how hard is the hard route, really?
11:31cemerickThere isn't much convention in this area, I don't think -- I've already spent more time thinking about serialization this morning than most devs think about it their entire career.
11:31cemerick</snark>
11:31rhickeyheh
11:32cemerickThe hard route is for the outlier in the hierarchy to implement Externalizable, which carries two methods (read/write), and is preferred over the default ObjectOutputStream regime.
11:33rhickeycemerick: my preference it to put it on the concrete classes. OTOH, one of the built-in icky things is that any base that has data must be Serializable, so Obj would bring it in in a lot of cases
11:34rhickeycemerick: but Externalizable isn't for opting out, it's for customizing, right?
11:34cemerickrhickey: right, one reason why I figured we should just put it on the abstracts.
11:34cemerickostensibly, but nothing keeping you from tossing an exception there, either. :-P
11:35rhickeymy long-term strategy is to get rid of Obj, but it seems to me the 'hard' alternative is to mark the concrete leaves Serializable
11:36cemerickMoving "Serializable" strings around isn't a big deal, just tedious and error-prone.
11:36rhickeyall derivees of ASeq will get it from there
11:37rhickeycemerick: it's more error prone to inherit Serializable and forget to defeat it
11:37cemerickinsofar as Obj (or its successor)'s derivees are values, then they *should* be serializable.
11:38rhickeyI'd say, take waht you get for free from Obj, then put the rest on the concretes
11:38cemerickOK
11:39cemerickThere needs to be a large warning that default Serialization is *not* for long-term storage.
11:39stuartsierraIsn't that a given with Java serialization?
11:39cemerickAt least until Obj implements Externalizable, and delegates to print-dup or something.
11:39cemerickstuartsierra: decidedly not
11:39stuartsierraoh
11:39rhickeycemerick: still need to audit ASeq derivees to ensure all are truly Serializable or fault as you described
11:40cemerickYeah
11:40cemerickIf I find any issues, we'll still have to use the writeObject trapdoor.
11:41rhickeycemerick: right, ok for now, and we can remove when Obj goes away
11:42cemerickstuartsierra: just think of all those in-process databases that allow you to quick-and-easy persist any object.
11:42AWizzArdcemerick: when you say that default serialization is not for long-term storage, do you then mean a) objects such as defrecords from Clojure, or b) jvm objects in general?
11:42rhickeycemerick: should move Serializable from AFn to AFunction I think?
11:43stuartsierracemerick: I thought they all relied on schema mappings, like Hibernate
11:43cemerickrhickey: er, yes, but why is AFn Serializable to begin with?
11:45rhickeycemerick: used to have data, and is base of some data structures
11:46cemerickAWizzArd: c) objects whose classes are apt to change in the future
11:46rhickeycemerick: but fns should serialize ok
11:47cemerickrhickey: how much do they capture?
11:47cemerickstuartsierra: Many do, many don't
11:47rhickeycemerick: the things they use. Obviously if they close over something non-serializable that won't work, but otherwise ok
11:48cemerickOh, I remember this now.
11:48cemerickAlong with a discussion about equality of fns.
11:49rhickeythe latter is a philosophical discussion we should avoid at present
11:49cemerickyes
11:49replacarhickey: I saw you scheduled the defmulti ticket. Do you want a ticket and patch for the corresponding declare issue as well?
11:50rhickeyreplaca: sure, thanks. I haven't had time to dig into that yet
11:50replacarhickey: ok, cool. I have no idea if my approach is the right one or not, so make sure you audit! :-)
11:51rhickeyreplaca: ok.
11:51rhickeybbl
11:54cemerickooh, clojure's build stomped on my pom.xml. Nice! :-D
11:59cemerickouch:
11:59cemerick,(= (into clojure.lang.PersistentQueue/EMPTY (range 5)) (into clojure.lang.PersistentQueue/EMPTY (range 5)))
11:59clojurebotjava.lang.NullPointerException
11:59stuartsierracemerick: Ant eats POMs for breakfast.
12:00cemerickstuartsierra: my carefully-crafted POMs, in particular. Thank goodness for local IDE history.
12:01stuartsierraYou need you POMs set in stone, to make them POM-o-granites.
12:04_brian2_noob question> can someone show me how to call this java constructor which uses a cast in clojure : http://clojure.pastebin.com/yFXbEKSQ
12:05stuartsierra_brian2_: just call it, no casting needed
12:05_brian2_ok, thnks
12:05stuartsierranp
12:06AWizzArd_brian2_: (let [compiled-classifier (AbstractExternalizable/compile classifier)] ...)
12:06_brian2_ok, thnks
12:06mmarczyk,(.equiv clojure.lang.PersistentQueue/EMPTY clojure.lang.PersistentQueue/EMPTY)
12:06clojurebotjava.lang.NullPointerException
12:13_brian2_AWizzArd: going back to my previous question, is this equivelant? (def compiledClassifier (. AbstractExternalizable compile classifier))
12:25cemerickmmarczyk: I've got a patch for that now.
12:25mmarczykcemerick: oh cool, can't wait to read it :-)
12:26cemerickNot much to it, I think it was just a copy/paste issue.
12:27mmarczykequals has the same problem
12:27cemerickyup
12:31MoominpapaHi, could someone help a newbie get Compojure working under Windows?
12:31MoominpapaI've got it built, but I'm trying to build a .ps1 file to run "Hello World"
12:32cemerickrhickey: you'll want this in 1.2: https://www.assembla.com/spaces/clojure/tickets/331
12:32sexpbot"#331 - Fix PersistentQueue equality methods (New) | Clojure | Assembla"
12:33lrennSo, I'm trying to use clojure from an ant task. This means clojure isn't on the system classpath, but is in the class.getClassLoader. I can reference clojure but RT.init fails since it's trying to use the system classloader. I can get around this by Thead.currentThread().setContextClassLoader(this.class.getClassLoader())
12:34lrennHowever, I'd like to avoid using any java, and write my tasks uses clojure and gen-class. Is there anyway to this without java?
12:38chouserlrenn: you might be able to aot-compile some clojure to do that kind of setup for youe
12:38chouseryou
12:40lrennchouser: the tasks themselves are aot compiled. Oddly enough, this all worked fine in clojure 1.0.
12:41lrenn1.0, worked fine with pure clojure and gen-class. 1.1.0, can't find clojure/core.clj during RT.init.
12:41_brian2_Moominpapa: as a fellow noob, I suggest not bothering with windows, it's an extra level of complication, atleast go with cygwin
12:42MoominpapaYeah, I spent several days on Ubuntu in VMware
12:42MoominpapaWhich worked, but was slower than treacle.
12:43_brian2_yea , you need a lot of memory for that
12:43MoominpapaThis was my next shot.
12:43MoominpapaWell, I've got 8G.
12:43_brian2_hmm
12:43MoominpapaSo maybe I just need to assign more to the instance.
12:43_brian2_dont know
12:43MoominpapaNor do I :)
12:44MoominpapaIt's annoying, I've solved everything else, including how to get lein to work on Windows (that was painful)
12:44MoominpapaMaybe I'll try cygwin :)
12:44_brian2_i suggest cygwin, its better than vmware route for this kind of thing
12:45_brian2_vmware is great for testing cluster's etc
12:46MoominpapaAnnoying, it was really easy to get working (barring a keyboard issue) but the performance wasn't really usable.
12:46MoominpapaQuery:
12:47MoominpapaYou still use Windows Java with Cygwin, or is there a special version?
12:47_brian2_no
12:47_brian2_everything is more or less transparent
12:48_brian2_no special version of anyhthing
12:48MoominpapaThat sounds promising.
12:48rshdo futures run on a fixed size thread pool?
12:49chouserno
12:49chouserblocking in a future is ok
12:52Blktis there a way to source-level debug Clojure?
12:54chouserBlkt: many java debuggers work, such as jswat and the one in netbeans
12:55Blktchouser: no way to have something like that with Emacs?
12:55chouserdunno. is there a java debugger for emacs?
12:56_brian2_Moominpapa: I also suggest downloading clojure box which is a windows prgram (and works in cygwin)
12:56Blktdfa2: we
12:57MoominpapaAaaaah
12:57MoominpapaThat I didn't know about. Thanks :)
12:57_brian2_good learning tool
12:58MoominpapaI'm mostly a .NET developer, but I'm feeling the need to learn something new and stop seeing things in terms of the tools I'm using.
12:59chouserbeware -- learning clojure and then not being required to use something else instead can threaten one's mental health.
12:59chouserer
12:59chouser-not
12:59chouserman, what a way to ruin a joke. :-P
13:00Moominpapalol (at the joke)
13:00_brian2_i was hoping that clojure would solve all my problems
13:03MoominpapaSo far, I've merely been encountering them. Six hours to "Hello World" and counting (yeah, I can do it in a repl)
13:11_brian2_Moominpapa: its a steep climb, I wasn't a lisper, but now I'll never go back, for me just dispensing with loops and indexes was enough
13:14MoominpapaC#'s already got rid of those :) (kinda) It's multi-methods that interest me.
13:14MoominpapaI'm looking forward to reconfiguring the way I look at things
13:15tufflaxCan one return multiple values in Clojure, as with 'values' in Common Lisp?
13:15hiredmanclojure uses the normal java method call stack, so no multiple returns
13:15tufflaxok
13:15chousertufflax: no, but it's not uncommon to return a vector of multiple values and use destructuring in the caller
13:16hiredmanyou can emulate multiple returns with binding and set!
13:16chouserbut that's not idiomatic or recommended. :-)
13:16tufflaxok, thanks guys
13:18hiredmanchouser: the docs for binding suggest that it is
13:19hiredmanin fact it is the only mentioned use for binding, none of this resource management stuff :(
13:19hiredman"Bindings created with binding cannot be seen by any other thread. Bindings created with binding can be assigned to, which provides a means for a nested context to communicate with code before it on the call stack."
13:20hiredmanbefore it, not after it
13:20chouseryeah, but how often have you seen that used?
13:21chouserI think it's mentioned because it's a non-obvious feature, not because it's recommended.
13:21chouserthe only place I've seen that done extensively is in the clojure compiler itself.
13:21chouserit's a bit scary and slated for removal, I believe.
13:22hiredmanonce the only legitimate use of binding is removed we can remove binding
13:22hiredmanactually the only place I have used that extensively is in a compiler
13:23chouser(binding [*foo* 0] (do-a-thing 5 "please") (prn *foo*)) ; <- printing anything other than 0 is scary
13:23hiredman*shrug*
13:24hiredmanyou don't call it *foo* you call it *result2*
13:24cemerickrhickey: record serialization doesn't work because of a namespace reference in there somewhere.
13:25MoominpapaI just figured out the classpath problem. The classpath was fine. The example I was using was junk. Should have been "compojure.core"
13:25hiredman(with-multiple-results (call 1) (println *result2*))
13:25MoominpapaStill don't work ofc... :)
13:25cemerickrhickey: if that can't be eliminated, then I can make namespaces sorta-kinda serializable (i.e. just have them look themselves up upon "deserialization").
13:26tufflaxchouser btw, I incidentally I saw your blog post "My path to Clojur" today :P How is your project euler solving coming along?
13:26chousertufflax: heh. haven't touched it in ages.
13:26tufflaxhehe, I have done it with python so far, I was thinking i should try some with clojure soon
13:27chouseractually, that's not quite true. I've spent much of the last week trying to fix up one of my solutions for inclusion in the book. I don't think it's going to make the cut, though.
13:27tufflaxClojure is a bit harder to learn than python, python one can learn in like an afternoon
13:28chousertufflax: I think it depends on what you're used to. But yes, if like me you have background in a "wide variety" of procedular syntaxy languages, clojure's a bit steep at first.
13:28chouserproject euler helped keep it fun.
13:28tufflaxBut learning python, and seeing the difference between python and java was what made me get around to trying lisp
13:30tufflaxwell, back to learning :=)
13:35MoominpapaGot it working! Thanks for the help :)
13:36MoominpapaAnd now my wife wants me... :)
13:37cemerickrhickey: ok, the namespace serialization issue ended up being straightforward, never mind.
13:39eslickIs there a way to have namespace A use symbols from namespace B such that if namespace C uses A it also gets the public names from B?
13:40chousereslick: not in a way that's recommended, I think.
13:41chouserof course C can use B directly
13:41Rayneschouser: What about D? ;)
13:42chouseror A can provide its own vars that have the same names and are bound to the same values as B's.
13:44eslickI regularly want to use utilities from multiple contrib namespaces and my own and am tired of cutting and pasting the same set of standard utility references to (ns (:use ...))
13:44eslickSo either I have a namespace that consolidates all these references that I can use
13:44eslickOr I can write a macro and insert it after the (ns ) statement which uses the appropriate libs
13:45Licensergreetings my lispy freinds
13:45eslickThis must be a common convenience issue, I was wondering if there was a canonical answer
13:45eslick(although heading off to grab lunch now...back soon)
13:49SynrGif B's public things are really A's public things, shouldn't they be made so explicitly, then? (def b b/b) or so
13:52SynrGexcept def is probably not right :p
13:54stuartsierraDuplicating Vars in multiple namespaces leads to subtle bugs.
14:01eslickWhat I really want is to have a "group alias" that allows me to :use names from multiple namespaces with a single reference.
14:02eslickso (:use my.libs.core) also gets me the equivalent to (:use clojure.contrib.str-utils)
14:02chouserThere are some replacement ns macros floating around that may have that kind of capability.
14:02eslickI used to have a 're-export' macro for CL that put third-party package symbols on the export list of a package
14:02eslickI'll check it out, thanks chouser
14:03chouserBut I think your own function to 'refer' what you want would be easy to write and not a bad idea.
14:05chouserwouldn't even have to be a macro. just (defn refer-common-set (doseq [x '[clojure.contrib.seq compojure.core ...]] (refer x)))
14:05chouserhm. though that's still 'naked use' which isn't so great.
14:06chousera function that requires and aliases a bunch for you might be ok.
14:07eslickA simple convention could be to :use 'my.utils.core which provides a simple function (use-standard-utils) which sucks in all the stuff I usually want to use
14:07eslickThen I just insert that after my ns statement and get the namespace I want
14:08cemerickit's very unfortunate that the signatures of set and sorted-set aren't the same.
14:08chouserhash-set and sorted-set are the same
14:08chouserhash-set and sorted-set have the same signature
14:09chouserset is like vec
14:09cemerickhrm
14:09cemerickyeah, but the fact that the latter is backed by the former is an impl detail
14:09cemerickoh, I see what you're saying
14:10cemerickI guess there should be a set-by to go with set and vec, then, to make everything analogous.
14:10cemerick(not that I'm actually suggesting that right now)
14:11chouseryeah, I see what you mean.
14:22cemerickchouser: how can I reliably ensure I'm getting a chunked seq?
14:23mmarczyka really nice Clojure question on SO:
14:23mmarczykhttp://stackoverflow.com/questions/2760017/producer-consumer-with-qualifications/2760224#2760224
14:23sexpbot"Producer consumer with qualifications - Stack Overflow"
14:23chouserdo you mean something other than 'chunked-seq?'?
14:23mmarczykI posted an answer
14:24mmarczykbut maybe some of you guys have better ideas (or comments on mine) :-)
14:25Chousukemmarczyk: I think you should use java's BlockingQueue thingies instead of making your own
14:25LauJensenmmarczyk: you should use while instead of empty recurs
14:26mmarczykLauJensen: right, thanks, that's a must! (going to fix it now)
14:26mmarczykChousuke: I guess so, but I was curious to see how it would work out without interop (except for sleep)
14:27mmarczykChousuke: I guess I might edit in an alternate version based on a blocking queue to make the answer more useful to the OP
14:29AWizzArd~max people
14:29clojurebotmax people is 283
14:30LauJensenI think its a fine a very readable example, so if that was what you were gunning for, I think you got it right :)
14:31mmarczykgood to hear that, thanks :-)
14:32mmarczykalthough I now notice I was supposed to have producers block if the queue gets too long, oh bother... going off to fix it
14:35LauJensen,(doc add-watch)
14:35clojurebot"([reference key fn]); Experimental. Adds a watch function to an agent/atom/var/ref reference. The watch fn must be a fn of 4 args: a key, the reference, its old-state, its new-state. Whenever the reference's state might have been changed, any registered watches will have their functions called. The watch fn will be called synchronously, on the agent's thread if an agent, before any pending sends if agent or ref. Note that
14:36LauJensenWhy are watchers still experimental ? Are they going away ?
14:43stuartsierraI think they're experimental because not many people have used them, thus the API hasn't been thoroughly tested.
14:43mmarczykugh, fixed now, but producer is a bit uglier now
14:43mmarczykI've used them just now to monitor queue lengths :-)
14:43mmarczykjust for debugging / general interest, though
14:44LauJensenstuartsierra: ah okay
14:47cemerickrhickey: FYI, excluded EnumerationSeq and IteratorSeq so far. I still need to do some trolling for potential transient targets and add more tests, but this is looking pretty decent so far: http://github.com/cemerick/clojure/commit/5d7224cd9f0
14:47LicenserI'm sing them for the swing stuff to update the gui when something chanes
14:58rshmmarczyk: i'd be interested to see how you would write it with java blocking queue; also, what is the overhead associated with an empty recur as opposed to a while?
14:59mmarczykrsh: there's no overhead (except some time spent macro expanding), as while is implemented in terms of (loop [] ... (recur)) :-)
14:59mmarczykrsh: as for the blocking queue version, I'm interested to see how I'd write it myself ;-)
14:59mmarczykrsh: so I suppose I'm going to do it in a moment
15:00mmarczykrsh: mostly I'd like to substantiate my claim that the code "would be easy to adapt" to a Java queue
15:01mmarczyknot all like it, though, I actually got downvoted :-)
15:01mmarczykoh well
15:02alexykI need to unroll a nested sequence, writing key pairs numbered: (doseq [[k1 v1] s] (doseq [[k2 _] v1] (put [k1 k2] i)) # I need to produce consequtive i's. Can this be done in doseq, or I'd have to use a loop?
15:11rshmmarczyk: can you explain why you used (ensure queue) instead of just @queue ?
15:13mmarczykrsh: to prevent write skew
15:13mmarczykrsh: if two producers found that (count @queue) is 3, they'd both place items on the queue
15:13mmarczykrsh: with ensure this won't happen
15:14mmarczykrsh: similarly with consumers; I wouldn't want two consumers to take the same element off the queue, then have the queue popped twice
15:15mmarczyk,(doc clojure.contrib.seq-utils/indexed)
15:15clojurebot"([s]); Returns a lazy sequence of [index, item] pairs, where items come from 's' and indexes count up from zero. (indexed '(a b c d)) => ([0 a] [1 b] [2 c] [3 d])"
15:16mmarczykalexyk: see above; the lib is called c.c.seq in HEAD
15:17alexykI read, from a database, a sequence where each element has the form, [[k1 k2] v]. I need to create from them a nested map, {k1 {k2 [v ...]}} -- is there a faster way to do it than update-in?
15:17alexykmmarczyk: thanks! Did it with a nested reduce (fn [i [k v]] ...)) for now
15:18alexykin the nested map, v's are conj'ed into an array
15:32mmarczykrsh: I added a java.util.concurrent.LinkedBlockingQueue-based version
15:32mmarczykrsh: it is indeed almost the same as the original :-)
15:33mmarczykalexyk: do you need the ordering of the vs to be preserved?
15:33rshmmarczyk: cool i'll take a look
15:35rshmmarczyk: how does ensure work under the covers? do the other transactions block until the transaction that got it first completes?
15:36mmarczykensure acquires a read lock on the Ref
15:37mmarczykso if some other transaction attempts to commit changes to an ensured Ref, it will fail and retry
15:38mmarczykif you never modify the ensured Ref in a transaction, that read lock will last you until the end of the transaction try
15:38mmarczykif you do, it will be released prior to acquiring the write lock when doing alter or sth
15:38mmarczykbecause read locks cannot be upgraded
15:39mmarczykso that's one scenario where another transaction could possibly slip in
15:39mmarczykget a lock after you released your read lock, but before you manage to acquire the write lock, I guess
15:39mmarczykif I understand the situation correctly...
15:40mmarczykbut consistency is still guaranteed, because your trans will notice that something is amiss and retry
15:40alexykmmarczyk: v's can be shuffled
15:40mmarczykalexyk: in this case, you could do two things
15:40mmarczykalexyk: the first one you could do anyway and that's moving to a transient map
15:41mmarczykalexyk: the second is splitting the work in chunks, building a couple of maps in parallel, each based on a subset of the data
15:41mmarczykalexyk: then merging the maps at the end
15:41mmarczykalexyk: this might make sense if your dataset is large enough
15:42mmarczykalexyk: you'd want to perform the merging with this function:
15:42mmarczyk,(doc merge-with)
15:42clojurebot"([f & maps]); Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping(s) from the latter (left-to-right) will be combined with the mapping in the result by calling (f val-in-result val-in-latter)."
15:42mmarczykalexyk: the `f' you'd be passing to merge-with would have to take care of concatenating the v vectors
15:43mmarczykalexyk: this is where some shuffling could conceivably occur, depending on how you handle things
15:50alexykis there an update-in! yet?
15:51mmarczyknope :-(
15:52alexykso if I run merge-with on a vector of a million triples, converting each to a small map, is it silly?
16:03mmarczykum, that's a bit hard to tell without knowing how did you come by all those triples ;-)
16:04mmarczykif it's all data from your db and you'd really like to merge it, then perhaps do a test run and see if it's fast enough
16:04mmarczykoh, now I'm not sure if I understood your question correctly
16:04mmarczykmerge-with accepts arguments which already are maps
16:06rshmmarczyk: your linkedblockingqueue solution really cleared up some things for me, thanks for your help. The only other question I have is that you use poll to prevent waiting forever..what is the clojure idomatic way of killing a thread if necessary?
16:17alexykif I reduce over triples, and find nested map is absent, do I get better performance creating it with (hash-map k v) vs. {k v} ? I.e., will the latter lead to changing the underlying map when it grows larger?
16:17Chousukemeasure it :)
16:18Chousukethough my guess would be that the difference is negligible
16:18alexykChousuke: I want the theory, not mere practice! :)
16:19alexykthe underlying will be destroyed anyways as it's not persistent... so probably just at one step a different thing will succeed previous one, indeed
16:21Chousukeare you trying to write update-in!?
16:22Chousukeor was it you who asked about it?
16:22mmarczykrsh: I'm not sure there is a general method of killing a Java thread, but in this case I now notice that I'm doing it all with futures and so could just hold on to them and kill them off with future-cancel at the end
16:23Chousukethere's the stop method of the Thread class, but it's deprecated
16:24replacadnolen: ayt?
16:24Chousukeit's the only way to really kill a thread though.
16:24dnolenreplaca: hola
16:25replacadnolen: hey, I wanted to give you a heads up that pprint is changing (moving into core and losing it's gen-classing), so we'll want to change the macroexpand in swank too
16:26mmarczykChousuke: I myself have witnessed it not work, though :-(
16:26replacadnolen: we'll keep it in contrib (deprecated) for another release, so it's not that much of a hurry, but it's on my mind today :-)
16:26mmarczyk(um, actually I meant to say "have myself")
16:27dnolenreplaca: cool, does this pertain to specific project of mine that you want to see patched for this change? (sorry a bit slow today)
16:27replacadnolen: didn't you add pprint to swank ages ago? Or is my memory getting fuzzy...
16:28dnolenreplaca: I did the first pass (in 2008 or something), but jochu actually tweaked my code quite a bit.
16:29technomancydnolen: that still leaves you as the person most qualified to patch it. =)
16:29technomancybut I'll do it eventually if you don't.
16:29dnolentechnomancy: haha :)
16:29dnolensure I can look into it.
16:30dnolenreplaca: are those changed pushed already?
16:30dnolenchanged -> changes
16:30replacayeah, I had to expand a macro this weekend (when I didn't have contrib loaded) and it was a disaster.
16:30replacaI was very sad :-)
16:30dnolenreplaca: ahh, so this was already pushed?
16:30replacadnolen: I just added the patch this morning, but I think it will go through very quickly
16:31replacadnolen: nah, I was working on my fork
16:31dnolenreplaca: ok just to be clear, what do I need to do to reproduce?
16:32leifwis there a transpose function that works on lazy-seqs?
16:33leifwnamely, (transpose '((1 2 3) (4 5 6))) #=> ((1 4) (2 5) (3 6))
16:33leifwwait that's just zip
16:33leifwhaha
16:34replacadnolen: once the patch gets pushed, load clojure w/o contrib on your path. Then expand a macro. Ewww! (though no different from what would happen in 1.1)
16:35dnolenreplaca: ok, will do.
16:35replacadnolen: But in 1.2, pprint will be clojure.pprint (and *also* clojure.contrib.pprint). But in the next release, clojure.contrib.pprint will go away
16:36replacadnolen: so, like I say, no real hurry
16:36technomancyreplaca: congrats on the promotion
16:36technomancyyou haven't had many changes to it recently, have you?
16:36replacatechnomancy: thanks much
16:36technomancybecause the downside of not being able to fix bugs on your own can really be a bummer. =\
16:37replacatechnomancy: no, not too much. I did make sure to close out the one open ticket before promoting it :-)
16:37clojurebottechnomancy is to blame for all failures
16:37dnolenreplaca: I suppose we want the fix to work with 1.1 and 1.2 ? what's the approach that was decided upon for supporting multiple version of Clojure?
16:37technomancyclojurebot: shut up, you.
16:37Borkdude,(apply map list '((1 2 3) (4 5 6)))
16:37clojurebot((1 4) (2 5) (3 6))
16:37clojurebotPardon?
16:37replacadnolen: I don't know - I would just try both, since we're trying things there anyway
16:38replacawhen we decide that 1.1 is acient history we can stop trying and charge blindly ahead
16:38replacaknowing that we have what we need
16:38replaca*ancient
16:39leifwBorkdude: doesn't work on lazy seqs I don't think
16:39technomancyI would like to support 1.1 in swank for a while, but if macroexpand turns ugly a few releases down the line I think that's acceptible.
16:39replacatechnomancy: There are still some big changes under the hood to come for pprint/format to support higher performance. But Stu promises that the delays won't be too bad :-)
16:39leifwBorkdude: yeah definitely doesn't
16:39technomancyreplaca: yeah, it has helped a lot bringing Stu on board.
16:42replacatechnomancy: the last few weeks have been a flurry of activity! I feel like we're getting some fit and finish as well as big conceptual features. More smart people with good taste = an even better language :-)
16:43Borkdudeleifw, I didn't follow what you wanted, just saw the zip/transpose thing
16:43technomancyreplaca: inc
16:44technomancy(anyone else find themselves usinc inc instead of +1 in circumstances where they won't be understood?)
16:44replacatechnomancy: admit it: you're a member of a cult :)
16:44BorkdudeIt's where others use InterlockedIncrement, inc sounds better
16:45replacatechnomancy: Q: is me having clojure as a dep in autodoc causing the problem that Joshua reported on the list?
16:45technomancyreplaca: pretty sure that's the culprit, yeah
16:46replacatechnomancy: and Q2: what's the best practice for pushing the fix to clojars, should I just push over the existing version 0.7.0 or make a new version?
16:46technomancyreplaca: I'd do 0.7.1
16:46technomancymight be able to get away with overwriting it since the code didn't change, but that's very iffy.
16:47replacatechnomancy: k, thx!
16:47stuarthallowayreplaca: I am seeing an issue with the new clojure group-by in the contrib pprint. Ok if I fix it?
16:49replacastuarthalloway: sure. where's the issue?
16:49replacastuarthalloway: oh, in the examples?
16:49stuarthallowaywhat I am seeing (locally) is the issue caused by group-by being promoted to clojure
16:49stuarthallowaybut I don't know why it wouldn't have broken the build
16:50replacastuarthalloway: what file? We don't AOT everything in contrib & we don't load the examples during testing.
16:50stuarthallowayyeah, this is making no sense atm
16:52stuarthallowayreplaca: nevermind. ancient build lurking on my machine
16:52replacastuarthalloway: ahh, ok
16:59leifwBorkdude: thanks for the help though
16:59leifwI think I got it
17:00stuarthallowayreplaca: the pprint move looks pretty good. anything in particular I should check before I mark it screened for Rich?
17:00leifwI'm just in a state where what I expect and what is true about lazy sequences are quite different, and I don't have a great handle on what functions are allowed to work with them and what aren't
17:00leifwbut it's all good now, I believe, my job continues to run
17:04leifwwhoo yeah
17:26tcepsaIs there a recommended way of using log4j in Clojure namespaces that you're going to compile into classes?
17:28tcepsaI'm trying to set up a logger but don't know how that would look; usually I create them a private static variables, but I can't figure out how to get the class name to instantiate the logger and I don't know how to make it static or private (though I can probably find the last two; it's the getting-the-class-name-to-Logger/getLogger that I'm having trouble with).
17:33eslickDoes count eval lazy sequences?
17:35dakroneeslick: looks like it does to me
17:35dakrone(count (map println [1 2 3]))
17:36dakrone,(count (map println [1 2 3]))
17:36clojurebot3
17:36clojurebot1 2 3
17:36eslickSo it's O(1) assuming the sequence has been fully evaluated
17:41eslickPS - nstools has an answer to my earlier question about 'cloning' common namespace use patterns
17:41replacastuarthalloway: nope, I think it's should be pretty straightforward for something so big
17:43eslickAny recommendations on doing production development on 1.1 or starting with the upcoming 1.2 now?
17:43eslickCommunity seems in transition; unclear which way to jump for a near-term project
17:51replacaeslick: unless you need some 1.2 features, I'd stick with 1.1. 1.2 shouldn't be too hard a conversion, but you might want to let the forward guard find library problems and such. Plus 1.2 is still changing every day right now (though that should end soon).
17:52eslickGood advice. That's where my head was, but I occasionally run into things depending on 1.2 and will avoid them for now.
17:52eslickthanks!
17:52MadWombatHello
17:52eslickLast silly question of the day...
17:52replacaeslick: np. Good luck!
17:52eslickWhat is the elegant way of (apply struct-map my-struct <map>)
17:53eslickwith a map of the keys and vals that I'd prefer were in an actual sequence
17:53eslickThis works for (apply struct-map my-struct [:a 1 :b2])
17:53eslickBut apparently not for (flatten (seq kvmap))
17:54eslickMadWombat: hi!
18:02MadWombatanyone configured auto-complete-mode to work intelligently with clojure?
18:03bmasonnot sure if this is what you're talking about, but auto complete seems to work fine in my emacs REPL, just not in the code files
18:04MadWombatbmason: yes, swank provides autocomplete to slime sessions, but I want autocomplete to work in the code
18:04MadWombatbmason: like with the fancy IDEs
18:04bmasonMadWombat: yeah understood... I don't know if the underlying mechanism is compatible
18:05bmasonMadWombat: I'm still new to emacs
18:05MadWombatYeah, me too
18:06_ato? you can use swank's auto-complete while editing source code
18:07_atojust use C-c <tab>
18:07MadWombat_ato: heh, gotta check
18:08_atomake sure you eval/compile the relevant parts of the file first so it knows what to complete on (C-c C-k should do the whole file)
18:08MadWombat_ato: cool, now I need to figure out how to plug this into auto-complete-mode
18:08MadWombat_ato: yes, of course
18:09BorkdudeC-c <tab>: good to know!
18:11dfa2MadWombat: in the case you care I've a macro that indents or complete only with TAB
18:11Borkdudedfa2, I care
18:11_atoBorkdude: (re: bookmark syncing on Conkeror) I don't use bookmarks, but I think it uses the same storage mechanism as firefox so some of the firefox bookmark syncing extensions might work with some tinkering
18:12Drakeson(deftype foo [a]) (foo. 10) -> ok (new (resolve 'foo) 10) -> broken
18:12Drakesonam I missing something?
18:13Borkdude_ato, ok tnx
18:13dfa2Borkdude: http://gist.github.com/388648
18:15Borkdudedfa2: gonna try that now
18:15technomancybut yeah... I wish Chromium would support extensions like that. =(
18:17Borkdudedfa2: am I supposed to reload slime to activate it or smth?
18:17dfa2Borkdude: no, just reload your .emacs with M-x load-file
18:17Borkdudedfa2: evaluating in *scratch* suffices as well?
18:18dfa2yep :)
18:18Borkdudedfa2, ah I had to reopen the clj file, now it works
18:18Borkdudegreat! :)
18:19dfa2^_^
18:19Borkdudedfa2: what's with the minibuffer in that code then?
18:23dfa2Borkdude: vestigial code :)
18:26Borkdudedfa2: right, I get it. This is going into my init.el now ;-)
18:28MadWombatseems like (add-hook 'clojure-mode-hook (setq ac-sources '(candidates . (slime-complete-symbol)))) works
18:46BorkdudeHmm, how do I get a pvt chat window in erc with someone?
18:49Borkdude/msg dfa2 ;; Thanks to dfa2 in #clojure
18:49Borkdude
18:54technomancyBorkdude: put the point on their nick and hit RET, then Msg
18:57Borkdudetechnomancy: tnx, maybe you only get a buffer for that person when a person talks to you, so it won't mangle up with your existing buffer?
18:58technomancyyup. not terribly fond of that choice, but that's how it works by default.
19:07rshif you send an agent several functions to run..do they run in the order in which they were sent?
19:08_atorsh: yes
19:09_ato(of course if they're sent from seperate threads the order might be non-deterministic, but functions sent sequentially from one thread will be executed in the order they were sent)
19:14Borkdudetechnomancy: I was after /query
19:23MadWombatI have a bunch of web site scrapers that I need to run in parralell and save the data in a database, at this point this is what I came up with http://pastie.org/944419 but it doesn't seem to parallelize and seems a bit awkward, what would be a better way?
19:25_atofutures might be more appropriate if you want to run them all in parallel
19:25_atopmap will only run up to the number of cores your machine has in parallel
19:25_atosince it'll be blocking on IO you probably want more than that
19:26_ato,(doc future)
19:26clojurebot"([& body]); Takes a body of expressions and yields a future object that will invoke the body in another thread, and will cache the result and return it on all subsequent calls to deref/@. If the computation has not yet finished, calls to deref/@ will block."
19:27MadWombathow do you wait for futures to actually execute?
19:27MadWombator will deref block until the particular future is ready?
19:29MadWombatah! got it
19:40BorkdudeWhen you have two futures in a let statement, can you see which finishes first?
19:53_atoI suppose you can loop checking (.isDone some-future), or have them do something side-effecty (like print "I'm done!") when they finish
19:55Borkdudehttp://gist.github.com/388755
19:55Borkdude_ato: I tried printing but that didn't work
19:56_atooh, if you're doing it in slime, printing from another thread usually goes to the *inferior-lisp* buffer, rather than the repl or minibuffer
19:56Borkdudeah, that explains it
20:09zakwilson_Does (vals a-map) make something like a full copy?
20:11MadWombat_ato: this is what I came up with, it seems to work, but somehow time macro doesn;t print anything http://pastie.org/944467
20:14MadWombatzakwilson_: I am not sure, but I don't think so. If I understand the concepts correctly the values in clojure are immutable, so there is no point in making a copy, clojure can just point you at the same values
20:14arohnerzakwilson_: no
20:15arohnerzakwilson_: vals creates a lazy seq that walks through your map
20:16zakwilson_Does it copy data at all, or just reference it?
20:16arohnerno copies at all. Since clojure datastructures are immutable, the map you have in hand will *never* change
20:16arohnerso it's never copied
20:17rshi want to change some of the font colors (particularly, for string) in clojure-mode for emacs, but don't see anywhere in clojure-mode.el that defines colors. Can someone point me in the right direction?
20:17zakwilson_I know it never changes. I just wasn't sure if the resulting seq would be structured so as to re-use the values.
20:18_atoMadWombat: why not just do (doseq [t threads] (deref t)) instead of the count loop? (or are you intending to print a status of the number that have finished so far?)
20:18_atowhere are you putting the time macro? inside each future?
20:20MadWombat_ato: (future (store-site (time ((val scraper)))))
20:21MadWombat_ato: I presume that deref will return nil immediately if the future is not done yet, or does it block?
20:21_atoah missed that, deref blocks
20:21MadWombatAh!
20:22_atohmm yeah, when I run 'time in a future the output goes to *inferior-lisp*
20:23MadWombatheh
20:23MadWombatthat is fine, this is for debugging only
20:24_atolooks like using (future-call (bound-fn [] (time ...))) will print it to the repl though
20:32MadWombat_ato: the latest version looks like this http://pastie.org/944490 and for some reason it runs sequentially (at least according to the log messages I get)
20:35_atoMadWombat: put a doall around your (for ...)
20:35_atothe 'for is lazy, so it's actually creating the futures until you deref
20:35_atodoall will force it
20:36MadWombat_ato: Ah! Lazy seqs!
20:36technomancyclojurebot: science is http://sunpig.com/martin/images/2008/10/iwilldosciencetoit.jpg
20:36clojurebotAlles klar
20:37pjstadigclojurebot: meap
20:37clojurebotManning missed the opportunity to call it Manning Early Access Trial
20:47defnAny ideas for pretty printing anonymous functions so they come out like #() instead of (fn* [p1__6334] (not= \: (first p1__6334)
20:48rshhow do I tell leiningen to put postgresql driver jar on the classpath?
20:48chouserdefn: whew, sounds tricky
20:48defnchouser: :)
20:48technomancydefn: you'd need to either write a decompiler or store the original pre-compiled source in metadata
20:48technomancythe latter wouldn't be bad if it were easy to turn off in production
20:48chouserwell, I dunno if it's *that* tricky
20:49defnwell the first option certainly wont be happening
20:49technomancythough it'd be a bit tricky to support with comp/partial/etc
20:49chouserhe seems to have the source as read
20:49defnyeah im doing (pprint (read-string "(foo #(bar %) baz)")) right now
20:50defnso the metadata thing is possible
20:50technomancydefn: I bet it's doable, but you'd have to deep-dive into the compiler. sounds like lots of fun if you've got some time to sink. =)
20:50_atorsh: add [postgresql "8.4-701.jdbc4"] to your :dependencies in project.clj? (not sure if that's the version you want, search jarvana.com)
20:51defntechnomancy: frankly i just have no clue where to even start, got some time to mentor me? ;)
20:51defnaka to sink? :)
20:52technomancydefn: I will bring it up for discussion at this week's seajure meeting
20:52technomancyit'd be a fun thing to try to track down
20:52defntechnomancy: oh man that'd be awesome
20:52technomancywill report findings, if any. =)
20:53defnfantastic! thanks!
20:53chouserdoes pprint not use a multimethod?
20:54defn!source pprint
20:54chouserah, perhaps I found it.
20:54technomancydefn: actually it's probably more of a reader thing than a compiler thing, which is good because at least two people in here know the reader pretty well.
20:54defnhiredman and chouser?
20:54technomancywas thinking of Chousuke
20:54defnah, yes
20:54technomancybut he probably does too
20:55defnof course he does :)
20:55defn</jealousy>
20:55replacachouser: yes, pprint uses a multimethod
20:55chouserclojure.contrib.pprint/*print-pprint-dispatch*
20:55replacachouser: in fact you can put any function you want in that var
20:56replacabut both code-dispatch and and simple-dispatch are multimethods
20:56chouseryou'd just want to implement a slightly different fn for PersistentList
20:57replacawhat's the question? I just dropped in
20:57replacaoh, defn
20:57replacajust use the code-dispatch
20:57defnpprinting #() as #() instead of (fn* [p_8142] ...)
20:57defnreplaca: that's all, really?
20:57replacait does that for you:
20:57chouserha!
20:58defnbahaha
20:58replaca(with-pprint-dispatch *code-dispatch* (pprint ...))
20:58replacait'll make your code all purdy
20:58defnpurdy codez
20:58replacanote the version that's going into core loses the ears
20:58replacasince it's not really meant to be rebindable
20:59defnfor 1.2 you mean?
20:59defnno more earmuffs?
21:00chouserI don't understand how to use code-dispatch
21:00replacayeah, it does all sorts of great things... nice indentation of let, if, etc.; quote turned into ' etc
21:00defnid like to know more if anyone wants to explain
21:00replacachouser: just like my example...
21:01chouserah, I see it now. thanks.
21:01chouservery nice
21:01replacadefn: earmuffs are those *s on the ends of *code-dispatch*. convention says you use them on vars that are meant to be rebound
21:01livingstonthe dispatch function on a mutimethod get's passed all of the function calls arguments right? but i just wanted to dispatch on the first I would give my dispatch function the signature [first & _] ?
21:01defnreplaca: ah-ha
21:02replacapprint has a ton of vars like that, but simple-dispatch and code-dispatch really aren't that way
21:03replacaif you want to customize, just create a new defmulti and default (if appropriate) back to the dispatch of your choice
21:03replacaif you look in the contrib examples there are examples of using custom dispatch to create xml or json
21:04replacalivingston: in this case it gets passed the object your pprinting
21:05replacait's called at each level - the idea is that you call pprint function from inside
21:05defnreplaca: which contrib examples
21:05livingstonreplaca: I'm only kinda following your dispatch question, .. I happen to have run into it myself too for a different question ;)
21:05replacalook in the contrib source in something like src/main/examples/pprint
21:06defnah, great -- thanks
21:06replacain any case, gotta run, bbl
21:11livingstonthe dispatch function in a defmulti gets called with every argument passed to the main function, right?
21:11defnbeautiful.
21:11defnso happy i didnt need to decompile
21:16bmasonso... Clojure being my first FP language, I'm really unfamiliar with the design approaches that are commonly taken
21:16bmasonis there some equivalent to design patterns for FP?
21:20livingstonbmason: there's a whole 'nother set of idioms you will want to get your head around, like map and reduce ... new core functions to the language that you probably won't be used to thinking with
21:22livingstonstarting with an intro book is probably the way to go (either for Common Lisp, Scheme or Clojure) and thinking about the exercises will help
21:22bmasonI read through Stuart Halloway's book
21:23bmasonI guess I'm looking for a more guided approach to designing and architecting a FP solution
21:24bmasonthe direction I'm planning now is to analyze source of some existing projects out there
21:24bmasonbut that's not quite the same as having an explanation of why a certain design was chosen
21:25livingstonbmason: that would be worthwhile, although I would encourage you to find a project and not a library (if you can).
21:25MadWombatwell, personaly I started with the SICP http://mitpress.mit.edu/sicp/full-text/book/book.html
21:25sexpbot"Structure and Interpretation of Computer Programs"
21:26rshwhat is the best way to go about writing database code in clojure? clojure.contrib.sql or clojureql? neither?
21:26rshsql database that is
21:26MadWombatit is in scheme, but it a good start into FP
21:26livingstonthe problem with SICP and On Lisp is they don't go about building large projects, but if you do what they guide you to do and the small level and build up, you'll do ok-ish
21:27bmasonhmm
21:27bmasonk
21:27MadWombatSpels in Clojure is supposed to be fairly decent
21:27MadWombathttp://www.lisperati.com/clojure-spels/casting.html
21:27bmasonI am planning to read On Lisp as well
21:27sexpbot"Casting SPELs with Clojure - Home -"
21:28MadWombathaven't read it yet
21:28bmasonvery nice
21:28bmasonI'll definitely dig into that
21:28remleduffrhickey: Sorry about the process mixup, submitting a patch to assembla before mailed my CA. I'll drop it in the mail tomorrow morning. Can I just say "I release this into the Public Domain" and make everything ok for now?
21:29livingston_ato: a fair enough goal
21:30bmasonlol, sounds like sage wisdom
21:30livingstonbmason: to the original question, I think if you just build up, step into working on something, start small, write one function to a function and refactor when possible, you'll get some decent code out of it.
21:30rhudson"Every big system that works well started out as a small system that worked well"
21:32livingstonthe advantage of starting in clojure is it will force a little more of the functional style on you, than you would get in a more mutable language like common lisp, which relies on discipline in stead of design to get good functional code
21:32bmasonah
21:32bmasonI wasn't aware that CL was different in regards to mutability
21:33bmasonbut yeah, I think it's appropriate for a language which requires you to *think* differently have a different syntax
21:33_atoI suppose the more general stuff applies when it comes to architecture. Build things in layers (so higher layers depend on lower layers) and avoid circular dependencies like the plague.
21:34bmasonok
21:34bmasonbut take something like Stuart Halloway's snake game
21:34Associat0r"CLI on the Web" http://tirania.org/blog/archive/2010/May-03.html
21:34sexpbot"CLI on the Web - Miguel de Icaza"
21:34bmasonin that, he has a function that returns a map containing all the doohickeys you need to run the game and find out what its state is
21:35bmasonwhich I thought was an interesting idea, and in a way it strikes me as a design pattern
21:35bmasona common way of doing things which applies to certain scenarios
21:36livingston(actually it *is* the state - as I remember)
21:36bmasontrue :)
21:37bmasonI figure there's probably volumes out there that describe that sort of thing in terms of where you would use it and why
21:38livingstonthe point to the example is that you're not side-effecting things (like you would be encouraged to do in a procedural language, for example) - you have a function you put in inputs you get out outputs - nothing else should change (if it's a pure function)
21:40livingstonthe input snake isn't modified, you just produce a new snake. and if you know the old snake can't change (like you are guaranteed in clojure) you are free to share any of it's structure in the new snake, making creating a "whole new one" really cheap
21:41bmasonright, and I get that
21:42bmasonI think he presented a good case for immutability
21:42bmasonmy question pertains more to resources for learning though
21:42livingstonthat's not really a "pattern" per say, it's just "what you do" in functional languages
21:42bmason:)
21:44livingstonbmason: oh, well, On Lisp isn't bad then, but it'll have you thinking in CL not Clojure
21:44bmasonknow of any web projects that are examples of good coding?
21:47livingstonbmason: not off the top of my head, in clojure at least (i liked the ones I built but those are published/available) I'm sure there are plenty of projects with open tasks looking for some help, you could try to contribute to though
21:48livingstonare published -> are not published/
21:48bmasonok... thanks for the ideas :)
21:48bmasonI may publish some of my stuff on github too and try to get some feedback
21:51remleduffbmason: I'm liking the cow blog: http://github.com/briancarper/cow-blog/tree/master/blog/
21:52remleduffI'm coming to the sad realization that my web project is not currently an example of good coding :\
21:52bmasonlol
21:53bmasonyeah, I'm sorta tackling a RESTful API at the moment
21:53bmasonso learning about doc types and HTTP headers at the same time as I'm picking up steam with Clojure
21:53remleduffI've been doing the same thing, never written a web app in my life
21:54remleduffSo decided to learn: clojure, emacs, compojure, enlive and fleetdb all at the same time
21:54bmasonwell heck, this is the first time it's seemed worth doing :-P
21:54livingstonwhen I say (ns ... (use a.b.c.d-e-f)) it's saying can't find a/b/c/d_e_f.clj on the class path? I can't have hypens? or is there something else I missed?
21:54remleduffreplace - with _ in your filenams
21:54bmasonweb technology is really starting to mature
21:55livingstonremleduff: really? that sucks - are hypens somehow invalid in java/jvm filenames?
21:55bmasonlivingston: is your file on the classpath?
21:55livingstonbmason: yes
21:56remleduffYeah, you can't have "-" in packages. So both "-" and "_" are mangled to "_" by clojure to allow it in namespaces
21:58livingstonugh - boo, but ok.. is *cringe* CamelCase preferred for this kind of thing?
21:58solussdand it's only a couple steps away from a monad. :)
21:58remleduffI think lots of people just name their file "some_package" and then (require 'some-package)
21:59remleduffI tend to avoid it and just add an extra directory to my package path
21:59remleduffSo it would be "some/package.clj" and (require 'some.package)
21:59livingstonremleduff: it's already 6 deep .. the underscore will do
21:59Associat0rsnake_case
22:03cemericklivingston: top-level namespaces are strongly discouraged.
22:05livingstoncemerick: I don't have any top level ns'es? like I said, I'm 6 deep already, you lose 3 just putting your institution on the front of the dang thing
22:05remleduffAt least you aren't in ".co.uk" ;)
22:06cemericklivingston: yeah, that was just an FYI :-)
22:06cemerickthere's no requirement to doing org.name.foo.bar.bang -- could easily be projectname.module.ns-name, etc.
22:07livingstonso let's say I have a lot of functions I want to dispatch on the same first arg, this would be an ok/correct dispatch function to give them all? (defn server-type-dispatch [server & _] (type server)) ?
22:08livingstoncemerick: yeah, I could probably get away with that too, but I'm in an academic lab that's integrating with a lot of java, so edu.... it is
22:09cemericklivingston: sure, or you can do #(type (first %&)) if you want to be concise about it. :-)
22:10livingstonI'll favor the readable one, for clarity, unless there is an efficiency argument to be made? this will get called *a lot*
22:11cemerickit's *slightly* more efficient (saving a var dereference), but the point is that the anon fn is semantically general (type of first argument), rather than declaring that it's a server type dispatch fn.
22:11cemerick*shrug*
22:15livingstonok, well I'll go with the obvious one until the profiler convinces me to do otherwise then
22:16remleduffcemerick: What is the apersand there?
22:16cemerickremleduff: rest arguments
22:17cemerick,(#(do %&) 1 2 3 4)
22:17clojurebot(1 2 3 4)
22:17remleduffinteresting, learn something new every day :)
22:17cemerick,(#(do [%1 %2 %&]) 1 2 3 4)
22:17clojurebot[1 2 (3 4)]
22:17livingstonI have to deal with the fact that I'm applying that dispatch function to many different defmulti's with different arity -and the dispatch function gets called with all the arguments of the main function so...
22:18cemerickfn literals have almost all of the argument options that normal fns do.
22:18livingstoncemerick: I would expect them to have them all? which ones are they missing?
22:19cemericklivingston: this is well into style and idiom here, but IMO, the best thing to do would be to def the fn literal in one place, but not specify that it's applicable only to servers, etc.
22:19cemericklivingston: It doesn't have rest kw args, which are a recent addition.
22:19remleduffIf I don't have a defstruct to dispatch by type on, is it ok to make a defmulti hierarchy that just dispatches assuming the first arg is a keyword I provide?
22:19livingstoncemerick: keywords like in common lisp? (that would be nice)
22:20cemerickremleduff: yes, though if you're using 1.2, it sounds like you'd be happier with records and protocols.
22:20cemericklivingston: essentially, yes.
22:21livingstoncemerick: well, the first arg is actually a map SO really it's calling (defn server-type-dispatch [server & _] (:server (type server)))
22:21cemerick,((fn [& {:keys [a b]}] [a b]) :a 5 :b 6)
22:21clojurebot[nil nil]
22:21livingstonalthough I guess I could do that with destructuring on the first arg too
22:21cemerickbleh
22:21cemerick,*clojure-version*
22:21clojurebot{:interim true, :major 1, :minor 1, :incremental 0, :qualifier "master"}
22:21livingstonyeah clojurebot is 1.1
22:21cemerickright, clojurebot doesn't have the newest stuff :-P
22:22livingstonthat's really nice though, something I was missing from CL - all these {} were really crudding things up
22:23cemerickA little sugar is good. :-)
22:24remleduffcemerick: What I was trying to ask was, is http://gist.github.com/388872 nonsense?
22:24livingstonit's a little ugly on the definition syntax, but getting it right in the calling syntax is more important
22:25anonymouse89hi all, quick question: what does "for[[a b] c]" mean?
22:25anonymouse89are a and b both taking values of c?
22:26cemerickremleduff: Seems fine to me.
22:26remleduffanonymouse89: It's using destructuring to take each element from the collection named c and split it into a and b which are available as vars inside the body of the for comprehension
22:26cemerick,(for [[a b] [[1 2] [3 4]] (+ a b))
22:26clojurebotUnmatched delimiter: )
22:26livingstonremleduff: does that even run?
22:27cemerick,(for [[a b] [[1 2] [3 4]]] (+ a b))
22:27clojurebot(3 7)
22:27remledufflivingston: I'm not sure, was typing it directly into gist
22:27livingstonlol
22:28livingstonfirst I don't think you give the argument signature to defmulti, do you? second it'll end up calling (#(identity %) key val) to dispatch which will barf because identity wants a single argument
22:29livingstonbut... on it's face, I don't see much wrong with the basic idea that I think you are going for
22:29anonymouse89remleduff: thanks
22:31livingstonremleduff: the thing is if it's a fixed set of stuff and you don't want/need it to be extendable by external code, then a code would probably be preferred (and possibly be more transparent)
22:32livingstoncode -> cond
22:32remledufflivingston: You're right, it didn't work. what I have now does, but seems a little iffy
22:33remleduffI guess a cond would work well too
22:34livingstonit'd be faster and more transparent as to what it is doing, but won't be externally extendable .. it depends on what you need....
22:34remleduffMy webapp is growing (str "/" user) or (str "/media/" item) all over the place and I've been trying to decide what the best replacement would be
22:35livingstonyou could also just have a map that associates keys with functions to apply to the value (that's basically what the defmulti is buying you.
22:36livingstoni'm ok with what you have, more or less, something about it seems ugly but I have no suggestion on how to better it if you need it to be defined distributed all over the place instead of a cond
22:37rhudsonA downside of cond is that it's linear search.
22:38rhudson(not an issue for a few keys)
22:40livingstonI don't know what the overhead is in clojure but with the Franz Allegro Common Lisp compiler you would have to exceed about 60 keys before a PList was slower than a hash-table
22:40livingstonthe hash implementations are significantly different though - has someone run that experiment here? we should
22:41livingstonregardless it's not really worth worrying about until the profiler get's upset at you
22:42jhawk28does anyone have any experience with writing an interpreter with Clojure? or should I look into using Antlr?
22:43cemericklivingston: array-maps cut over to hash-maps @ 16.
22:43hiredmanare you kidding? writing an interpreter in a lisp vs java stuff?
22:43hiredmanmultimethods are great for interpreters
22:43slyphonhiredman: yeah, but java's got...
22:43slyphon...stuff
22:44hiredmanpfft
22:44jhawk28it needs to be able to execute (like the string reader) from Java code, but it is an s expression syntax
22:44slyphon:)
22:44hiredmanyeah, multimethods all the way
22:44cemerickhiredman: BNF is really nice when it fits
22:45livingstonright, but the jumps in hashes can do funny things to CPU lookahead compared to some more straightforward things - so you gotta measure it at the task at hand (presumably RIch did and found the break at 16)
22:45hiredmanyou can't see me rolling my eyes
22:45jhawk28the grammar is predefined
22:45jhawk28its LL too
22:46cemericksomething implemented in a common grammar is so very, very often superior to something that's hand-rolled.
22:46livingstonI just call read
22:46cemerickThere's good reasons to hand-roll things, but it shouldn't be the default choice.
22:47slyphonthat's one thing that impressed me w/ scala, is the built-in BNF parsing stuff
22:47slyphonthere's something neat about being able to do stuff like that
22:47cemerickslyphon: you shouldn't be. Stuff like that shouldn't be in a general-purpose language.
22:47cemerickThat's what libraries are for, quite literally.
22:48slyphoni mean, i think it was factored out into a standard library, like the embedded-xml functionality
22:48slyphonit's been a while since i've looked at it, though
22:49cemerickI ended up having to use the embedded XML stuff quite a bit. Nightmare, pure nightmare.
22:49slyphonyeah?
22:49cemerick<xml><blah><foo>.........</foo></blah></xml>.callSomeXMLDOMMethod()
22:49cemerick:-0
22:50slyphonhrm
22:50slyphonyeah, i could see how that could get hairy
22:50slyphonbut still, it looks damn cool!
22:50cemerickit gets crazier, as you can interpolate values into the XML
22:50cemerickyeah, it's very alluring, if you haven't gotten tangled in stuff like it before.
22:50slyphon:)
22:51livingstonanything with a closing tag (that's required) is already inferior to an s-expression
22:52slyphon)
22:52livingstoncemerick: I don't know that library, but jQuery is pretty damn cool for js stuff, and sounds like it has similar applications
22:53slyphoni heard a statistic the other day, that jQuery has 80% penetration
22:53cemericklivingston: was talking abou tthe inline XML support in scala?
22:53cemerickI was*
22:54livingstonI haven't looked at scala too much. it's primary selling point being "it's not java" wasn't quite good enough for me.
22:54jhawk28thanks for the tips
22:54slyphonwell, "It's functional not java"
22:54jhawk28Ill look into the multimethods
22:54slyphon"..and it gives the guys at Twitter a stiffie"
22:54remleduffWhat does penetration mean for something downloadable by 100% of people with javascript?
22:55slyphonremleduff: it means 80% of the sites these guys were surveying were using it in one form or another
22:55cemerickthat's probably a lowball estimate
22:57slyphonany language you can't use paredit to hack on is at a distinct disadvantage
22:57livingston.. headed out, dinner etc. -- thanks everyone
22:59remleduffI'm coming to emacs from a vim addiction, and still not really liking emacs as an editor, but paredit is amazing
22:59mmarczykremleduff: I know what you mean, that's what got me hooked :-)
22:59slyphonyeah, i use vim for pretty much anything that's not s-exp based
22:59mmarczyk...and now I'm using ERC to chat with you guys :-P
22:59slyphonhahaha
23:00slyphonit's a slippery slope;2~
23:00mmarczyk:-)
23:00slyphon!
23:00mmarczykwell I always was curious about the dark side
23:00slyphon:D
23:00mmarczykso it wasn't a painful switch, because I already knew my way around :-)
23:01mmarczykI use both Vim and Emacs now, makes for fun little lapses of concentration
23:01slyphonoy
23:01slyphonand tangled fingers
23:01mmarczykwhere I'm quitting Vim with C-x C-c :-P
23:01slyphonC-g!
23:01slyphonor manically hitting ESC in emacs
23:01mmarczykC-g is exactly what I press when I realise it doesn't make sense to press C-x C-c in Vim :-)
23:02mmarczykand before I actually regain my senses ;-)
23:03remleduffI still can't believe how many commands I use *frequently* take 2 or even three control characters
23:03slyphonyeah
23:03slyphonvim-mode in emacs saves me a lot of heartache
23:04slyphonremleduff: see, you're not supposed to use those keystrokes, you're supposed to reprogram the editor over the course of 10-15 years until it's an extension of your now corrupted mind
23:04mmarczyk:-D
23:04remleduffhehe
23:04slyphon:)
23:04mmarczykthat's the Emacs mindset summarised for you right there
23:05slyphoni had to stop with emacs a few years back, because i was having *way* more fun hacking on my editor than actually "doing work"
23:06remleduffI'm close to quitting emacs again now, every since I've changed computers I get a 3 second pause every time I try to open a file
23:06slyphonreally?
23:06slyphonweird
23:07remleduffenough editor digression from me though :)
23:08slyphon:)
23:10mmarczyk:-)
23:20ndimidukcan multimethods be implementations of an AOP-exposed object's methods?
23:21ndimidukfor instance, i'd like to export MyClass.foo(Integer) and MyClass.foo(String). Can i use a multimethod to implement these methods?
23:21ndimiduk(defmulti -foo class) kind of thing.
23:24chouserndimiduk: you mean to implement a gen-class method? Yeah, I think that should work.
23:24ndimidukchouser: that's precisely what i mean
23:40TakeVSo, the two ways to implement a Java interface in Clojure is either with :gen-class or a proxy, right?
23:41remleduffUntil 1.2 comes out at least
23:43TakeVOh? I tend to use the 1.2 branch mostly, so how do you do it in there?
23:43TakeVOr has it not been implemented yet?
23:43cemerickTakeV: there's reify, deftype, and defrecord now
23:43_atohttp://clojure.org/datatypes http://clojure.org/protocols
23:44cemerickFar fewer use cases these days for gen-class and proxy.
23:47ndimidukchouser: yep, that works perfectly! thanks
23:48ndimidukTakeV: i've been using quite a bit of gen-{class,interface} lately
23:48ndimidukTakeV: because i'm implementing classes to be consumed by an external java framework
23:49ndimidukTakeV: it's pretty nice to keep most of the code in clojure. only troubles arise when you have generic-typed objects in the interfaces