#clojure logs

2010-12-31

00:20amalloyBerengal: hey, are you on the xkcd forums? i don't read them often, but i happened across a Berengal just now recommending shell scripting
00:21Berengalamalloy: Yeah, that's me
00:21tanukiShould I get "Clojure in Action" or "The Joy of Clojure"?
00:27amalloytanuki: depends what you want, i'm sure. i don't know who wrote CiA, but if you get JoC you can hassle the author in #clojure
00:28tanukiThey cancelled "F# in Action", so I'm considering getting a Clojure book instead
00:28tanuki(I like Lisp syntax more than ML syntax anyway)
00:33technomancyget the Joy of Clojure
00:35tanukiwhich is why I leaned toward F# at first
00:37qbgGetting closer towards a release of my syntax-rules lib
00:42qbgParsing the macro usage is easy; putting together the expansion is hard
00:43Clintegerf#'s syntax confuses me so much
00:44tanukiIt's not nearly as elegant as Lisp, but it's not horrible
00:44tanukiit's just kinda goofy at first
02:12LauJensenMorning :)
02:25scottjIn case anyone's interested, Arc has this interesting (and poorly documented) feature called ssyntax, which I think stands for symbol syntax.
02:28scottjit allows things like (inc:dec 1) => ((comp inc dec) 1), (str a!name b!name) => (str (:name a) (:name b)), ~a => (complement a), (a.b c) => ((partial a b) c), (a&b c) => (and (a c) (b c))
02:33LauJensenThat looks really nice
02:43scottjit could probably be used for evil ($pr:+.10:filter.<20?&~even?.l1!l2) :)
03:41Deranderscottj: call it a new language: "nospace"
04:20LauJensenDerander: only "J" gets that title
05:10ejacksonGood Morning #clojure, and goodbye 2010 !
05:38LauJensenejackson: Goodbye!! :)
05:39ejacksonLauJensen: you're changing you're name to 2010 ? Its a bit radical :)
06:38fliebelmorning
06:45ejacksonmorning fliebel
07:08maaclLauJensen: In moustache is there a way of getting at the querystring ?
07:11raekmaacl: accessing the query params is usually done by http://clojuredocs.org/ring/ring.middleware.params/wrap-params
07:12raekmoustache only does four things: wrap handlers, dispatch on HTTP request URI, dispatch on HTTP method and render plain text
07:14maaclraek: OK, but how would I combine the two? moustache dispatch + get at the querystring when I handle the request?
07:15raek(app wrap-params ["foo"] {:get get-foo-handler} ["bar"] {:post post-bar-handler})
07:16raek(defn get-foo-handler [{:keys [params], :as request}] ...)
07:16raekmaacl: did you want to select the handler by looking at a query parameter?
07:18maaclraek: yeah that was the idea
07:18raekmoustache cannot do that, but you can very easily implement that yourself
07:20maaclraek: yes, thanks
07:20raek(defn dispatch-on-param [param handlers] (fn [{:keys [params], :as request}] (let [value (get params param), handler (get handlers value)] (handler request))))
07:21raekmaacl: this is my idea of what it could look like
07:21raekcalling (dispatch-on-param "foo" {"a" handler-a, "b" handler-b}) will return a handler that delegates everything to one of the given handlers
07:22raek(app wrap-params ["foo"] {:get (dispatch-on-param "foo" {"a" handler-a, "b" handler-b})})
07:23maaclraek: yeah, looks elegant - would work after having dispatched on request and method, right?
07:25raekyes, you can plug it in at any place the moustache syntax labels as "(some clojure code)": http://moustache.cgrand.net/syntax.html
07:28fliebelIf I wanted to do some sort of message queue, what would I use? Lamina looks real nice, but I need something that works transparently over a network. Could I do this with Aleph, or would it be better to use a project with a name that ends in 'mq'? Lamina over *mq would be nice...
07:28kumarshantanufliebel: consider using HornetQ -- it's based on Netty and exposes HTTP interface
07:29fliebelkumarshantanu: Thanks, will check it out.
07:31ejacksonfliebel: I'd suggest RabbitMQ if you're being serious, and Redis (no really) if its just a toy.
07:31ejacksonfliebel: with redis you can have something up in 10 minutes :)
07:33fliebelejackson: Are you saying RabbitMQ is hard?
07:33ejacksonfliebel: not at all, its harder than redis is all :)
07:34ejacksonrabbitmq has exchanges and queues and stuff to wrap your head around. They have a product that can survive powerdowns and other bad stuff, so neccessarily is more complex.
07:35ejacksonredis will give you a pubsub channel in no time but isn't going to be as robust, and I'm not sure how it handles multiple readers of a channel etc.
07:35ejacksoncheck out : http://simonwillison.net/static/2010/redis-tutorial/
07:36fliebelejackson: I don't know if I need al that. What I want to do is write a little game using a message system, and use the same system later for multiplayer, either local or over a network.
07:38ejacksonredis might work for that. at any rate, its so easy to get going that you'll lose very little finding out.
07:38ejacksonif you discover you need some clever handling of the queues, then upgrade to a proper messaging system
07:40fliebelejackson: Thanks, I'll take a look at that as well.
07:40ejacksonlemme know how you get on :)
07:40fliebelejackson: I'm just in the gathering-ideas mode, so it'll brobably be a while.
07:57bmhWhat is the third argument to state-m-until?
08:01fliebelbmh: You could have told me it's in clojure.contrib.monads ;)
08:01bmhfliebel: sorry
08:02fliebelbmh: I don't know, but see for yourself: https://github.com/richhickey/clojure-contrib/blob/master/src/main/clojure/clojure/contrib/monads.clj#L401
08:03bmhah-ha. I missed the state argument at the bottom (fn [s] ... )
09:51duck1123so does anyone know what I should be using for contexts in lazytest 2 now? I'd really like to find something similar to rspec's before(:each) but can't see how to do that.
09:52duck1123If I had a var to hook onto, something like add-hook would do well for me. (that way I could wrap my bindings)
10:23_na_ka_na_ hellos, is there a way to change 'binding in all threads in this context' kinda thing? w/o doing alter-var-root
10:24@rhickeyhttp://news.ycombinator.net/item?id=2054230
10:27fliebelrhickey: I looked as hard as I can at clojure.lang.Atom, but I still don't see why swap uses state.compareAndSet. I also came up with another alternative for the interface: Add a constructor that takes a AtomicReference. People can subclass that to customize atom in that case.
10:27@rhickeyfliebel: I thought the question was why can't it be isA AtomicReference?
10:28fliebelrhickey: I asked to many in one go, I guess. I figured that one out I think.
10:29@rhickeyfliebel: I think not as it applies to your suggestion right now - subclassing AtomicReference is futile as everything is final
10:29RaynesIntense. I've never heard such emotion rhickey before. I like it.
10:33fliebelrhickey: Atom is final, but AtomicReference doesn't seem to be. Or is that my mistake?
10:34@rhickeyhttp://download.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/atomic/AtomicReference.html
10:34@rhickeyfliebel: look - all the interesting methods are final
10:35fliebelrhickey: I… need to refresh my Java. I didn't know *methods* could be final. Thanks for clearing that up. Back to the drawing board.
10:37fliebelrhickey: That leaves me with the swap question, why does it use state.compareAndSet? https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Atom.java#L81
10:39fliebelIt seems Atom.compareAndSet would work, and handles validating and notifying just the same.
10:40@rhickeyfliebel: it could, probably due to order of implementaiton
10:42fliebelrhickey: Splendid! Now, that means I can supposedly implement swap in Clojure and drop it of the interface. Objections?
10:43@rhickeyfliebel: yes
10:45fliebeloh
10:46@rhickeywhy?
10:46clojurebothttp://clojure.org/rationale
10:46@rhickeyaargh
10:47nickikrhickey: I looked at dylen a bit and i think the multimethodes are pretty cool there too. Have you thougt about implementing something like dispatch on values? http://99-bottles-of-beer.net/language-dylan-225.html
10:48@rhickeynickik: yes, CL has dispatch on values
10:48nickiksomething like a standard dispatch function that works like dylans
10:48@rhickeyfliebel: I don't want to preclude implementations of Atom that use locks
10:48@rhickeynickik: not interested
10:49@rhickeynickik: been there, done that
10:50@rhickeyif you always want values, you can use identity as a dispatch function
10:50@rhickeymixing values and dispatch fn means double lookup
10:51fliebelrhickey: That… Is… a good point. So much to learn still… Thanks. :)
10:52nickikrhickey: ah ok so its for speed reasons or are there other objectives?
10:52@rhickeyfliebel: you can interface-ize the stuff the Clojure code uses, but new interfaces that change the shape of things require design time - not a priority now
10:53@rhickeynickik: speed and simplicity
10:53fliebelrhickey: I understand.
10:53nickikrhickey: ok thanks I wounderd about that for a while.
11:00_na_ka_na_rhickey: In my tests I keep wanting a cousin of binding which binds across threads... is there a way out w/o using alter-var-root ?
11:01@rhickey_na_ka_na_: what does it mean to bind across threads?
11:09_na_ka_na_rhickey: I mean a construct like (binding-across-threads [a 10] @(future (prn a)) works ..
11:10_na_ka_na_but binding-across-threads can be spawned many times concurrently w/o affecting each other
11:10_na_ka_na_I don't know how to achieve that though
11:11@rhickey,(clojure-version)
11:11clojurebot"1.2.0"
11:11_na_ka_na_(map deref (map #(future (binding [a %] @(future (prn a)))) (range 2)))
11:12@rhickey_na_ka_na_: regular binding does that now in master
11:12_na_ka_na_oh, that's awesome! I'll take a look
11:13_na_ka_na_how about creating a bot which runs 1.3-master on IRC ?!
11:15_na_ka_na_,(try (finally (doseq [_ [1 2]])))
11:15clojurebot_na_ka_na_: I don't understand.
11:15Bronsa_lol
11:16_na_ka_na_@(try (finally (doseq [_ [1 2]])))
11:16_na_ka_na_I forgot how to run the Rayne's bot
11:17_na_ka_na_rhickey: I don't have a CA can I still submit a bug on jira?
11:17edoloughlinDoes if-let treat nil as true? My code at https://gist.github.com/761119 isn't behaving as expected.
11:17tonyl&(try (finally (doseq [_ [1 2]])))
11:17sexpbotjava.lang.UnsupportedOperationException: Cannot recur from catch/finally
11:18_na_ka_na_ah yes thx tonyl
11:18tonyldoseq uses loop/recur
11:18_na_ka_na_, (if-let [a nil] 1 2)
11:18clojurebot2
11:18@rhickey_na_ka_na_: yes, but not a patch without a CA
11:19_na_ka_na_edoloughlin, are you sure your expression in if-let returns nil?
11:19_na_ka_na_try inserting a trace
11:20edoloughlin_na_ka_na_ - yes. I'm using the (dbg) macro and also eval'ing it in the REPL
11:21edoloughlinMy actual code returns the binding-form, which is set to nil
11:24pdk(doc dbg)
11:24clojurebotHuh?
11:24cemerick_na_ka_na_: no, you don't need a CA to submit a bug report.
11:27edoloughlin_na_ka_na_ - seems I'm suffering from blame-the-compiler syndrome. As soon as I share the problem I spot the cause. Thanks.
11:35r2q2hi
12:10mduerksendo i understand this correctly: protocols always establish a type-based dispatch, so i can't implement different methods for different keywords (inside the same method, i could of course still distinguish with a cond). right?
12:11qbgRight
12:12nickikthey methodes dispatch on the first argument
12:12mduerksenok, thanks
12:15r2q2Is there any code checked in for the clojure to clojure compiler?
12:16nickikthere is alread a clojure in clojure compiler but not an offical one
12:16r2q2Where is that
12:16nickiki cant find it anymore
12:16nickiksomewhere on github
12:17r2q2ok
12:19nickikits kind of hard to find we talked about it in here maybe you find something there
12:21qbgIt was also announced on the group
12:22r2q2Oh i found it
12:23r2q2https://github.com/jarpiain/cljc for further refrence
12:51TheLolrusHi. I'm a python programmer interested in clojure. Should I learn Java before learning Clojure?
12:51dakroneTheLolrus: it's not required at all
12:53TheLolrusOK. Would I be recommended to learn emacs? :P
12:54headlessClownA familiarity with the java virtual machine and classpaths isn't a bad idea but not necessarily java the language.
12:54dnolenTheLolrus: or NetBeans, or Textmate, or Vim, or Eclipse, or IntelliJ
12:54headlessClownlots and lots of clojure devs use emacs but there are other ways
12:54clojurebotclojure is making your sexp smile
12:55BronsaAlol
12:55TheLolrushmm if only there was a scribes plugin.
12:55dnolenTheLolrus: if you're not afraid of ruby, the cake project management tool you can pretty much use a regular text editor if you want.
12:55headlessClownMe personally, i tried vimclojure and the netbeans plugin before trying to learn emacs/slime/leiningen
12:56headlessClownAnd I'm sticking with emacs
12:56TheLolrusmkay. Would you guys recommend any tutorials besides the reference guide? A book perhaps?
12:57TheLolrusBy the way the reason I don't want to learn emacs is I'm an impatient 13 year old. :P
12:57qbgTheLolrus: That is a good reason to learn emacs :)
12:57TheLolrusheh
12:57headlessClownJust start using emacs for any ole text editing
12:58TheLolrusI mean impatient to learn all the keyboard commands and get used to it
12:58tonylTheLolrus, you can use any text editor
12:58qbgThere aren't that many for basic use
12:59headlessClownI'm double your age, kid, and I picked up emacs (basic command set) this last summer :p
13:00TheLolrusMaybe next summer when I have freedom :D
13:01TheLolrusSo are there any good clojure books or introductions? That explain it in detail. Then I can dive into the reference guide.
13:01dnolenTheLolrus: have you done much functional programming before?
13:02headlessClownThere are couple on the book shelf and a couple that are releasing soon.
13:02TheLolruswell. Python has functions. I have tried C a few times but never got far in it. xP
13:02TheLolrusso not much.
13:02qbgFunctional programming is more than just functions
13:03TheLolrusI thought so
13:03TheLolrusso no, then.
13:03qbg,(map inc [1 2 3])
13:03clojurebot(2 3 4)
13:03TheLolrusnope. :P
13:04dnolenTheLolrus: well Joy of Clojure is really good, but it assumes some experience w/ functional programming (FP)
13:04qbgProgramming Clojure is nice also
13:04dnolenStuart Halloway's book Programming Clojure is not a bad place to start, though perhaps getting long in the tooth now.
13:04trptcolin_TheLolrus: you might also take a look at http://learn-clojure.com/
13:04qbgA lot of it still applies
13:04headlessClownHas Joy of Clojure shipped yet?
13:05headlessClownie the MEAP edition
13:05r2q2Maybe? http://www.amazon.com/Joy-Clojure-Thinking-Way/dp/1935182641/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1293818813&amp;sr=8-1
13:06qbgIt says Jan 28, 2011
13:07headlessClownahhh
13:07qbgThat bestsellers rank is far too low...
13:08TheLolrushow about http://www.youtube.com/user/briantwill#g/c/AC43CFB134E85266
13:08currentBsimple question: what is the best way to generate a list filled with a given number of other lists, should i use for?
13:08qbgcurrentB: example?
13:09qbg,(repeat 5 [1 2 3])
13:09clojurebot([1 2 3] [1 2 3] [1 2 3] [1 2 3] [1 2 3])
13:09qbg?
13:09r2q2Aren't richhickeys webcasts still relevant
13:09qbgr2q2: They should largely still be
13:09r2q2TheLolrus: You should probably watch those
13:09qbgThe syntax has changed since the older ones, but not much
13:10currentByup repeat is perfect (sometimes i get hung up on which simple fn i'm looking for) thanks!
13:11TheLolrusI'm thinking those videos, then http://en.wikibooks.org/wiki/Clojure_Programming/Concepts , then http://java.ociweb.com/mark/clojure/article.html
13:12midsTheLolrus: sounds like a good start
13:19midsI just bought The Joy of Clojure e-book... the PragProg order process is so much nices than Manning :(
13:30qbgI reimplemented condp using my syntax-rules lib: https://github.com/qbg/syntax-rules/raw/master/src/qbg/syntax_rules/examples.clj (see ex-condp at the bottom)
13:30qbgI need a more powerful templating language eventually...
13:31qbgThe syntax is simple, the template is hard...
13:32Raynesqbg: Why did you give the raw link? :o
13:32Rayneshttps://github.com/qbg/syntax-rules/blob/master/src/qbg/syntax_rules/examples.clj is prettier
13:32RaynesIn any case, that is pretty awesome.
13:34qbgI'd try to reimplement for if I only understood how it works...
13:35Raynesfor is insanity.
13:35qbg95+% of the work would be in the template anyways...
13:35qbgProbably not worth it.
13:35RaynesIt's probably the one thing I'm having the most trouble explaining in my book. I've mostly left it as a placeholder until it comes to me in a dream or something.
13:36Raynescemerick: Have you explained it in yours yet? /me will leech inspiration.
13:36qbgFor is easy to implement in Scheme
13:36qbg(relatively easy that is)
13:37qbgcontinuations help a bit
13:40qbgI should make a release in the next few days
14:09fliebelI just noticed someone mentioned https://github.com/jarpiain/cljc in here. *amazed* What is the status of that?
14:26pdkconsidering it mentions the 1.3 alphas in the readme it's probably pretty recent
14:26pdk1.3 hasn't gone gold yet
14:49cemerickRaynes: explained what?
14:56bhenrywhat is non-lazy map?
14:59qbgcemerick: Raynes was talking about for
15:00bhenryi want to do a function with side effects to every item in a seq
15:00cemerickbhenry: (doseq [x some-sequence] (println x))
15:00cemerickfor example
15:01bhenrythanks
15:06pdkdo/doseq/dotimes basically exist for side effects
15:08cemerickqbg: yeah, we'll be covering for
15:10TheLolruswhat's so good about maven?
15:10pdkthe name sounds like mavis beacon
15:10pdkthat's what we like with t
15:10pdkit
15:12qbgMaven treats XML like violence
15:13TheLolrusthe enclojure site looks epic
15:13TheLolrusI wonder if it's made in clojure :P
15:17cemerickTheLolrus: this is now a bit old and out of date, but should give you some context about why one might use maven: http://cemerick.com/2010/03/25/why-using-maven-for-clojure-builds-is-a-no-brainer/
15:18TheLolrusmkay
16:03amalloyqbg: syntax rules is intimidating, even with the examples. the simple macros look promisingly simple, but even slightly non-trivial ones like -> are hard to follow. do you have a link to a good intro/tutorial?
19:05devnwell, I won't be doing much for the next year
19:08qbgThe title of Clojure in Small Pieces makes it sound like it would be like Lisp in Small Pieces, but it is not
19:08qbg(LiSP is a good book by the way)
19:59pdkwhere do you find clojure in small pieces
19:59pdkalso is LiSP worth it if you've read graham's acl
20:13Adamantpdk: yes, it's a implementation of a language system book
20:13Adamantjoshua__: agreed
20:14pdkso there's still stuff to learn from it
20:14Adamantjoshua__: I've been known to pay for things then immediately use the pirated version due to that being the easiest
20:14Adamantpdk: probably, unless you're already a compiler geek
20:14pdkda f is with the pricing
20:14pdkis this like on lisp
20:14Adamantit's expensive
20:14Adamantthey aren't printing more copies, IIRC
20:14pdkwhere there's a freebie version but a physical copy will cost you your first born
20:14Adamantcheck to see if they released a e-copy
20:15pdknot on kindle at least
20:15Adamantalso look at several bookstores
20:16joshua__Adamant, I think I'm going to do that actually.
20:17joshua__The other funny thing is how much is charged for lets say, "Structure And Interpretation of Computer Programs."
20:18joshua__Charging well over $50 for a book that is free is a bit wacky to me.
20:18Adamantthat's a hardback with pretty awesome binding
20:18pdkif you think it's bad take a look at on lisp
20:18pdkgraham gives you a free pdf
20:18pdkor you could go $140 for hardcover
20:18qbgYou could get LiSP from a good library
20:19Adamant$140 is most of a Kindle or half a NOOKColor
20:19Adamantmore than half, actually
20:19joshua__I suppose that its a good thing that it is all overpriced for the dead tree edition. Less dead trees and all.
20:19Adamantmostly it's due to it not being reprinted
20:19AdamantI expect
21:11DeranderAdamant: it's all of a kindle if you go for the wi-fi only version.
21:11AdamantDerander: not surprised
21:11AdamantI wasn't up on current prices :P
21:12Derander:-P
21:53auseris there a non-lazy form of filter?
21:56cemerickauser: doall will force evaluation of any lazy seq
21:56auserthat's what I thought...
21:56auserthx
23:24duck1123What is a good clojure 1.3 replacement for re-partition?
23:33joshua__duck1123, what do you mean?
23:34duck1123re-partition was in str-utils, which is no longer in contrib 1.3
23:34duck1123so I'm trying to find a good replacement
23:37joshua__duck1123, I don't know, but the source is at https://github.com/richhickey/clojure-contrib/blob/a1c66df5287776b4397cf3929a5f498fbb34ea32/src/main/clojure/clojure/contrib/str_utils.clj#L28 if you can't find an option.
23:38duck1123I've been going through the dependencies of my application and seeing what it takes to get them all to play nice with 1.3. I'm working on autodoc right now
23:39duck1123the changes with the string-related libs has been a pain
23:54replacaduck1123: how's it going with autodoc? I haven't turned on 1.3 yet, but I have a new version in the works that should be more multiversion friendly
23:59programblehappy new year!