#clojure log - Sep 23 2008

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

9:34 StartsWithK: should i call (agent-errors) periodicaly just to flush list of exceptions?

9:34 rhickey__: aren't the exceptions telling you something isn't working?

9:35 or just to detect the error?

9:35 StartsWithK: just to detect errors while developing

9:37 rhickey__: that or dereferencing will do it, the latter throwing

9:40 StartsWithK: (def a (agent nil)) (send a (fn [& args] (throw (Exception. "test"))) (deref a) (agent-errors a)

9:41 agent-errors still show list with "test" exception

9:41 rhickey__: they'll be there until you clear them

9:42 yangsx: hi, what is the best match for Common Lisp's assoc in clojure?

9:43 rhickey__: yangsx: use maps instead of alists

9:43 {:a 1 :b 2}

9:44 yangsx: rhickey__: yeah, thanks, just trying to learn clojure by porting PAIP code

9:45 rhickey__: one of the problems with straight ports of PAIP or SICP is that you miss out on a lot of Clojure's benefits

9:47 StartsWithK: why are (symbol "test test") and (keyword "test test") legal?

9:47 yangsx: sure, but I can gain better insight the difference between the two, and clojure specific features can be left for the next turn

9:48 leafw: yangsx: clojure looks like lisp, but it's not lisp in many regards. leaving clojure features for the next turn doesn't strike me as wise.

9:48 rhickey__: yangsx: I disagree, pretty strongly. lots of that code is imperative and you'll just struggle trying to emulate it

9:49 yangsx: so I should change the order :)

9:50 porting PAIP code is challenging

9:50 rhickey__: yangsx: The real challenge is functional programming, not the minor syntax differences

9:51 yangsx: rhickey__: I can program in functional style, but haven't try the pure way yet

9:53 rhickey__: yangsx: that's good, then it shouldn't be too bad. But at each point where Clojure differs, it pays off to learn why. For instance, it would be easy to do alists in Clojure, but I don't recommend it because they don't scale. You can use maps right from the start and they will.

10:00 yangsx: besides reading the wikibook and the official website and Stuart's blog porting PCL, are there any other resources helping me (from CL) to learn Clojure?

10:01 Chouser_: rhickey__: have you considered adding watchers to refs, similar to the new agent watchers?

10:03 Chouser: I sometimes think I want that, although then I often realize I want more than just the new value -- I also want some kind of delta or diff with the old value.

10:03 ...in which case it's probably more appropriate to write my own hash-map class or something to log the changes.

10:06 drewr: yangsx: At this point, it's best just to start with a problem and try to write the code to solve it.

10:09 yangsx: drewr: OK

11:01 rhickey__: Chouser: I have, not sure about old/new value. I've left it out for now. I think it is a violation of encapsulation in some ways - watchers could/should be calling functions to get at parts of the state they care about.

11:21 aking: Any chance that clojure would work under Android? It works fine (though slow) with jamvm on the iphone.

11:23 rhickey__: aking: that would require AOT compilation, since there is no dynamic bytecode loading on Dalvik. I've been looking at AOT compilation recently and getting on Android would be one of the reasons to do it

11:24 aking: that'd be cool. One the iphone with jamvm, it seems to be running about 150-200x slower with the one benchmark I tried.

11:25 rhickey__: are all java things 150x slower?

11:26 aking: godd question. I'll try a quick benchmark from the shootout

11:27 good* .. ugh.. my typing is bad this morning... more coffee

11:33 running 'time java binarytrees 14' gives 0.487s on my system and 40.804s on the iphone

11:34 cemerick: rhickey__: speaking of AOT compilation, you mentioned line numbers being an issue last week -- wouldn't emitting all of the java source corresponding to a line of clojure on a single line give you the desired result?

11:35 rhickey__: cemerick: there is JSR 45, it's just a post compilation step to add that info to the classfiles

11:36 might be some issues with tracking classes generated by inner classes

11:45 ozzilee: Ok, not my problem or business, but it bugs me. Shouldn't experimental things like agent watchers be added in a branch of the repository, rather than in trunk?

11:47 blackdog: or stick to the release version

11:49 rhickey__: branches are time-drains

11:50 ozzilee: I suppose.

11:50 cemerick: there'd probably be dozens of branches if things were allowed to bifurcate due to newness at this point

11:50 rhickey__: most new features are in the, don't use it, don't care category

11:50 and if there are repercussions, I want to know asap

11:51 blackdog: also, i think git or mercurial make branching easier- to beat abrooks drum :P

11:51 * blackdog hides

11:52 rhickey__: I'll put my productivity in developing Clojure up against any other model

11:52 * cemerick glowers @ blackdog ;-)

11:54 rhickey__: it works for me, not advocating for anyone else

11:55 but the branching vs usage is important, if only the few people who were interested in agents were running that code, it would be far less tested than by having it in head

11:58 ozzilee: Makes sense to me.

12:34 shoover: StartsWithK: I didn't see an answer to your question from a couple hours ago. clear-agent-errors is the other way to get rid of them

12:36 Chouser: clojure-log seems to be missing Next/Previous in Chrome :(

12:45 drewr: Yet another browser to check. :-(

12:47 ozzilee: I don't see Next/Previous in Safari either. Same engine.

12:47 drewr: Oh, well that's good.

12:47 ozzilee: (web rendering engine I mean)

12:47 drewr: So are Chrome tabs basically a bunch of Safari processes?

12:48 ozzilee: Well, webkit processes I guess.

12:48 Chrome has its own Javascript engine though, separate from Webkit/Safari's.

12:49 drewr: Yeah, V8.

12:49 ozzilee: Yeah. The rendering is webkit though. I don't know much of the details.

12:49 I do know it's an older version of webkit than the current Safari uses.

13:30 Chouser: shoover: try the site again?

13:30 it should be fixed

13:31 shoover: Chouser: indeed

14:03 StartsWithK: shoover: thanks

14:16 *agent* is bind to current agent, and you can (send) to *agent*?

14:19 i'm reading http://is.gd/318H producer-consumer example, and *agent* is used in example but i can't fint it on clojure.org in documentation

14:22 Chouser: StartsWithK: I think you're right, but *agent*'s never been particularly documented.

14:43 fyuryu: StartsWithK: *agent* is the current agent, I remember rhickey mentioning it in the concurrency talk

16:43 StartsWithK: is it ok if i do (send (agent nil) action), i mean, is agent cheap or should i store him somewhere?

16:45 or.. hmm, could i merge producer and consumer and remove ref in a way that same agent gets two action that like in that example call themselfs, and both operate on agents state?

16:46 (let [a (agent nil)] (send-off a produce) (send-off a consume))

16:55 shoover: StartsWithK: you could, but you need two agents if you want the actions to run in parallel

22:05 yangsx: no documentation for recur in http://clojure.org/api though it's mentioned in clojure.markdown, a bug?

22:25 arohner: (reduce (fn [x y]) [])

22:25 java.lang.IllegalArgumentException: Wrong number of args passed to: eval--4705$fn (NO_SOURCE_FILE:0)

22:25 is that expected? it seems like a better error message could be thrown

23:00 Chouser: yangsx: recur is a special form, and thus is not on the api page

23:00 yangsx: (doc recur)

23:53 yangsx: Chouser: special forms are special? :) but (doc recur) does not work here: Unable to resolve var: recur in this context

23:53 arohner: what version of clojure are you running?

23:53 yangsx: though I've understand recur now

23:54 arohner: yangsx: (doc recur) was added in svn r1034

23:55 yangsx: arohner: I see, my current copy's not updated

Logging service provided by n01se.net