#clojure log - Sep 27 2008

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

0:11 abrooks: rhickey: Cool news about the conference and the performance on the Azul boxen. Was Cliff impressed?

0:13 rhickey: I hope your weekend is restful. Are you flying, driving or taking the Acela out for Monday?

0:13 rhickey: abrooks: I think he was more surprised - he's a bit of an STM skeptic, but he acknowledged that Clojure's model might work, in his talk today :)

0:14 driving

0:14 abrooks: rhickey: Very cool -- he may be convinced yet. :)

0:15 rhickey: I think I made progress with both he and Brian Goetz, in explaining how Clojure's STM approach is different

0:17 abrooks: rhickey: We'll I'm looking forward to the talk on Monday. I've got a bunch of friends who are quite excited to be there too.

0:18 rhickey: great! it will be nice to meet you

0:21 pjb3: rhickey: On the issue of why clojure maps aren't java.util.Maps, would I be correct in saying the reason why is that clojure maps are java.util.Collections, and it's impossible for any java class to be both a Collection and a Map, because those two interfaces have remove methods with conflicting return types?

0:21 rhickey: pjb3: exactly

0:22 pjb3: damn, that sucks

0:22 abrooks: rhickey: Heh. And you likewise! Thanks for doing these talks. I hope you feel they're rewarding as I belive the community does.

0:24 rhickey: abrooks: I do

0:24 pjb3: yeah one of the few warts in java.util

0:24 MO

0:24 IMO

0:25 pjb3: It's a big one though, this makes interoperating clojure with existing java apis difficult

0:25 best thing we can do is copy the clojure map into a HashMap and pass that to a java method that expects a Map, right?

0:26 rhickey: pjb3: I'm on the fence about it, people have asked both for it to be changed and for it to stay as is...

0:26 pjb3: no, we can make a flyweight that implements Map and delegates to a Clojure map

0:27 pjb3: Ah, right, that's not as bad, you don't have nearly as much overhead

0:28 rhickey: been talked about here a few times - no one's gotten around to it yet

0:28 It should be implemented in Java

0:28 pjb3: sure

0:29 rhickey: then we can have a (jmap amap) fn

0:29 gotta board my plane...

3:55 StartsWithK: if i have (def a [:a1 :a2 :a3 :a4 :a5]) (def b [:b1 :b2 :b3 :b4 :b5]) and would like to combine them so i get [:a1 :b2 :a3 :b4 :a5]

3:55 would this be a best way o do it

3:55 (map (fn [[t a b]] (if t a b)) (partition 3 (interleave (iterate not true) a b)))

4:06 cgrand: StartsWithK: (map #(if %1 %2 %3) (iterate not true) a b)

8:52 scook0: is there an existing macro out there that lets you declare variables "in-line"?

8:52 i.e.

8:53 (my-do (foo bar) (<- var (some expression)) (frob var))

8:54 I could probably do it myself, but I'd rather not if it's already been done before

9:42 StartsWithK_: scook0: there is nothing like that in clojure

9:42 scook0: yeah, that's what I figured

9:43 StartsWithK_: but you can just write (my-do (foo bar) (let [v (some expression)] (frob v))

9:43 scook0: that's exactly what I wanted to avoid having to do myself, hence the macro

9:44 StartsWithK_: i don't see how will your macro work, you will still have nesting if that is what you want to eliminate

9:44 scook0: sometimes I just want to bind a name to something without having to add another layer of nesting

9:44 the idea is that my-do will scan for <- in its subforms

9:45 and expand out into the nested form

9:45 this might not have been clear from my example

9:45 StartsWithK_: so you will have my-do instead of let ?

9:46 scook0: yeah (or instead of do)

9:46 I suppose I could just do everything inside the [] of a let

9:47 but that feels wrong if I have a lot of side-effectful calls that I'm not interested in the value of

9:47 StartsWithK_: that will be very complicated macro, if not impossible

9:47 (my-do (<- v1 5) (println v1) (<- v1 6) (println v1))

9:47 scook0: I can't see why

9:49 it would expand to (do (let [v1 5] (println v1) (let [v1 6] (println v1))))

9:49 StartsWithK_: (my-do (<- v1 5) (println v1) (<- v2 (+ v1 10)) (println v2) (<- v1 (+ v1 v2)) (println v1))

9:50 scook0: I'm still not seeing the difficulty

9:50 what's supposed to be hard there?

9:51 StartsWithK_: nothing it seams :)

9:52 scook0: macros are funny things though

9:53 mostly I seem to find myself using them to get around the things I don't like about s-expressions ;)

9:56 blackdog: http://www.tbray.org/ongoing/When/200x/2008/09/25/JVM-Summit

10:03 StartsWithK_: i tried to use socket repl from wiki

10:03 but there are some problems

10:04 syntax errors i produce in it can crash my server, and all exceptions are printed on shell where server is started

10:04 is there maybe finished socket repl that is more advanced?

12:39 achim_p: StartsWithK_: swank-clojure (the emacs/slime mode) uses a socket repl, AFAIK. http://github.com/jochu/swank-clojure/tree/master

16:15 hi

16:15 rhickey: i needed to deal with java.util.Maps, so i had a go at the jmap thing. would that be worth submitting as a patch or is it off track?

16:16 lisppaste8: achim_p pasted "jmap" at http://paste.lisp.org/display/67534

16:46 Chouser: achim_p: cool!

16:47 rhickey won't accept patches over IRC, so if you want it in your best bet is to post it to the google group. You'll also need to send in a CA if you haven't.

16:47 rhickey: achim_p: the key is to avoid copying in keySet()/entrySet() and values() (all those create calls copy). You'd want to look into using the Abstract... stuff from java.util to create flyweights to return from these calls

16:47 patch welcome with CA

16:56 achim_p: rhickey: okay! i was sceptical about that part ... i'll look into it tomorrow.

16:56 what about about the cast in wrap(), is it safe to assume that a subclass of APersistentMap won't return something that's not a APM upon cons, assoc, without etc.

16:56 at the moment that's the case

16:57 the cast is only needed if cons, assoc, ... on jmaps are to return jmaps - not sure if that's necessary

16:58 arohner: probably a stupid question, but if I want to call a clojure function from java, is there a way to do that without gen-class, gen-interface?

17:02 achim_p: arohner: does RT.var("namespace", "fn").invoke(args) work?

17:02 havent tried it

17:03 arohner: I was considering approaches, I don't have enough code to try it out yet

17:06 StartsWithK_: achim_p: thanks for link to swank-clojure

22:43 Guest20927: Are there licensing alternatives for clojure besides CPL?

Logging service provided by n01se.net