#clojure logs

2008-09-27

00:11abrooksrhickey: Cool news about the conference and the performance on the Azul boxen. Was Cliff impressed?
00:13abrooksrhickey: I hope your weekend is restful. Are you flying, driving or taking the Acela out for Monday?
00:13rhickeyabrooks: 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 :)
00:14rhickeydriving
00:14abrooksrhickey: Very cool -- he may be convinced yet. :)
00:15rhickeyI think I made progress with both he and Brian Goetz, in explaining how Clojure's STM approach is different
00:17abrooksrhickey: 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.
00:18rhickeygreat! it will be nice to meet you
00:21pjb3rhickey: 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?
00:21rhickeypjb3: exactly
00:22pjb3damn, that sucks
00:22abrooksrhickey: Heh. And you likewise! Thanks for doing these talks. I hope you feel they're rewarding as I belive the community does.
00:24rhickeyabrooks: I do
00:24rhickeypjb3: yeah one of the few warts in java.util
00:24rhickeyMO
00:24rhickeyIMO
00:25pjb3It's a big one though, this makes interoperating clojure with existing java apis difficult
00:25pjb3best thing we can do is copy the clojure map into a HashMap and pass that to a java method that expects a Map, right?
00:26rhickeypjb3: I'm on the fence about it, people have asked both for it to be changed and for it to stay as is...
00:26rhickeypjb3: no, we can make a flyweight that implements Map and delegates to a Clojure map
00:27pjb3Ah, right, that's not as bad, you don't have nearly as much overhead
00:28rhickeybeen talked about here a few times - no one's gotten around to it yet
00:28rhickeyIt should be implemented in Java
00:28pjb3sure
00:29rhickeythen we can have a (jmap amap) fn
00:29rhickeygotta board my plane...
03:55StartsWithKif 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]
03:55StartsWithKwould this be a best way o do it
03:55StartsWithK(map (fn [[t a b]] (if t a b)) (partition 3 (interleave (iterate not true) a b)))
04:06cgrandStartsWithK: (map #(if %1 %2 %3) (iterate not true) a b)
08:52scook0is there an existing macro out there that lets you declare variables "in-line"?
08:52scook0i.e.
08:53scook0(my-do (foo bar) (<- var (some expression)) (frob var))
08:54scook0I could probably do it myself, but I'd rather not if it's already been done before
09:42StartsWithK_scook0: there is nothing like that in clojure
09:42scook0yeah, that's what I figured
09:43StartsWithK_but you can just write (my-do (foo bar) (let [v (some expression)] (frob v))
09:43scook0that's exactly what I wanted to avoid having to do myself, hence the macro
09:44StartsWithK_i don't see how will your macro work, you will still have nesting if that is what you want to eliminate
09:44scook0sometimes I just want to bind a name to something without having to add another layer of nesting
09:44scook0the idea is that my-do will scan for <- in its subforms
09:45scook0and expand out into the nested form
09:45scook0this might not have been clear from my example
09:45StartsWithK_so you will have my-do instead of let ?
09:46scook0yeah (or instead of do)
09:46scook0I suppose I could just do everything inside the [] of a let
09:47scook0but that feels wrong if I have a lot of side-effectful calls that I'm not interested in the value of
09:47StartsWithK_that will be very complicated macro, if not impossible
09:47StartsWithK_(my-do (<- v1 5) (println v1) (<- v1 6) (println v1))
09:47scook0I can't see why
09:49scook0it would expand to (do (let [v1 5] (println v1) (let [v1 6] (println v1))))
09:49StartsWithK_(my-do (<- v1 5) (println v1) (<- v2 (+ v1 10)) (println v2) (<- v1 (+ v1 v2)) (println v1))
09:50scook0I'm still not seeing the difficulty
09:50scook0what's supposed to be hard there?
09:51StartsWithK_nothing it seams :)
09:52scook0macros are funny things though
09:53scook0mostly I seem to find myself using them to get around the things I don't like about s-expressions ;)
09:56blackdoghttp://www.tbray.org/ongoing/When/200x/2008/09/25/JVM-Summit
10:03StartsWithK_i tried to use socket repl from wiki
10:03StartsWithK_but there are some problems
10:04StartsWithK_syntax errors i produce in it can crash my server, and all exceptions are printed on shell where server is started
10:04StartsWithK_is there maybe finished socket repl that is more advanced?
12:39achim_pStartsWithK_: swank-clojure (the emacs/slime mode) uses a socket repl, AFAIK. http://github.com/jochu/swank-clojure/tree/master
16:15achim_phi
16:15achim_prhickey: 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:16lisppaste8achim_p pasted "jmap" at http://paste.lisp.org/display/67534
16:46Chouserachim_p: cool!
16:47Chouserrhickey 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:47rhickeyachim_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:47rhickeypatch welcome with CA
16:56achim_prhickey: okay! i was sceptical about that part ... i'll look into it tomorrow.
16:56achim_pwhat 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:56achim_pat the moment that's the case
16:57achim_pthe cast is only needed if cons, assoc, ... on jmaps are to return jmaps - not sure if that's necessary
16:58arohnerprobably 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:02achim_parohner: does RT.var("namespace", "fn").invoke(args) work?
17:02achim_phavent tried it
17:03arohnerI was considering approaches, I don't have enough code to try it out yet
17:06StartsWithK_achim_p: thanks for link to swank-clojure
22:43Guest20927Are there licensing alternatives for clojure besides CPL?