#clojure logs

2008-09-23

09:34StartsWithKshould i call (agent-errors) periodicaly just to flush list of exceptions?
09:34rhickey__aren't the exceptions telling you something isn't working?
09:35rhickey__or just to detect the error?
09:35StartsWithKjust to detect errors while developing
09:37rhickey__that or dereferencing will do it, the latter throwing
09:40StartsWithK(def a (agent nil)) (send a (fn [& args] (throw (Exception. "test"))) (deref a) (agent-errors a)
09:41StartsWithKagent-errors still show list with "test" exception
09:41rhickey__they'll be there until you clear them
09:42yangsxhi, what is the best match for Common Lisp's assoc in clojure?
09:43rhickey__yangsx: use maps instead of alists
09:43rhickey__{:a 1 :b 2}
09:44yangsxrhickey__: yeah, thanks, just trying to learn clojure by porting PAIP code
09:45rhickey__one of the problems with straight ports of PAIP or SICP is that you miss out on a lot of Clojure's benefits
09:47StartsWithKwhy are (symbol "test test") and (keyword "test test") legal?
09:47yangsxsure, but I can gain better insight the difference between the two, and clojure specific features can be left for the next turn
09:48leafwyangsx: 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.
09:48rhickey__yangsx: I disagree, pretty strongly. lots of that code is imperative and you'll just struggle trying to emulate it
09:49yangsxso I should change the order :)
09:50yangsxporting PAIP code is challenging
09:50rhickey__yangsx: The real challenge is functional programming, not the minor syntax differences
09:51yangsxrhickey__: I can program in functional style, but haven't try the pure way yet
09:53rhickey__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:00yangsxbesides 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:01Chouser_rhickey__: have you considered adding watchers to refs, similar to the new agent watchers?
10:03ChouserI 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:03Chouser...in which case it's probably more appropriate to write my own hash-map class or something to log the changes.
10:06drewryangsx: At this point, it's best just to start with a problem and try to write the code to solve it.
10:09yangsxdrewr: OK
11:01rhickey__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:21akingAny chance that clojure would work under Android? It works fine (though slow) with jamvm on the iphone.
11:23rhickey__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:24akingthat'd be cool. One the iphone with jamvm, it seems to be running about 150-200x slower with the one benchmark I tried.
11:25rhickey__are all java things 150x slower?
11:26akinggodd question. I'll try a quick benchmark from the shootout
11:27akinggood* .. ugh.. my typing is bad this morning... more coffee
11:33akingrunning 'time java binarytrees 14' gives 0.487s on my system and 40.804s on the iphone
11:34cemerickrhickey__: 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:35rhickey__cemerick: there is JSR 45, it's just a post compilation step to add that info to the classfiles
11:36rhickey__might be some issues with tracking classes generated by inner classes
11:45ozzileeOk, 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:47blackdogor stick to the release version
11:49rhickey__branches are time-drains
11:50ozzileeI suppose.
11:50cemerickthere'd probably be dozens of branches if things were allowed to bifurcate due to newness at this point
11:50rhickey__most new features are in the, don't use it, don't care category
11:50rhickey__and if there are repercussions, I want to know asap
11:51blackdogalso, i think git or mercurial make branching easier- to beat abrooks drum :P
11:52rhickey__I'll put my productivity in developing Clojure up against any other model
11:54rhickey__it works for me, not advocating for anyone else
11:55rhickey__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:58ozzileeMakes sense to me.
12:34shooverStartsWithK: 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:36shooverChouser: clojure-log seems to be missing Next/Previous in Chrome :(
12:45drewrYet another browser to check. :-(
12:47ozzileeI don't see Next/Previous in Safari either. Same engine.
12:47drewrOh, well that's good.
12:47ozzilee(web rendering engine I mean)
12:47drewrSo are Chrome tabs basically a bunch of Safari processes?
12:48ozzileeWell, webkit processes I guess.
12:48ozzileeChrome has its own Javascript engine though, separate from Webkit/Safari's.
12:49drewrYeah, V8.
12:49ozzileeYeah. The rendering is webkit though. I don't know much of the details.
12:49ozzileeI do know it's an older version of webkit than the current Safari uses.
13:30Chousershoover: try the site again?
13:30Chouserit should be fixed
13:31shooverChouser: indeed
14:03StartsWithKshoover: thanks
14:16StartsWithK*agent* is bind to current agent, and you can (send) to *agent*?
14:19StartsWithKi'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:22ChouserStartsWithK: I think you're right, but *agent*'s never been particularly documented.
14:43fyuryuStartsWithK: *agent* is the current agent, I remember rhickey mentioning it in the concurrency talk
16:43StartsWithKis it ok if i do (send (agent nil) action), i mean, is agent cheap or should i store him somewhere?
16:45StartsWithKor.. 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:46StartsWithK(let [a (agent nil)] (send-off a produce) (send-off a consume))
16:55shooverStartsWithK: you could, but you need two agents if you want the actions to run in parallel
22:05yangsxno documentation for recur in http://clojure.org/api though it's mentioned in clojure.markdown, a bug?
22:25arohner(reduce (fn [x y]) [])
22:25arohnerjava.lang.IllegalArgumentException: Wrong number of args passed to: eval--4705$fn (NO_SOURCE_FILE:0)
22:25arohneris that expected? it seems like a better error message could be thrown
23:00Chouseryangsx: recur is a special form, and thus is not on the api page
23:00Chouseryangsx: (doc recur)
23:53yangsxChouser: special forms are special? :) but (doc recur) does not work here: Unable to resolve var: recur in this context
23:53arohnerwhat version of clojure are you running?
23:53yangsxthough I've understand recur now
23:54arohneryangsx: (doc recur) was added in svn r1034
23:55yangsxarohner: I see, my current copy's not updated