#clojure logs

2008-05-27

03:33albinoDoes clojure pay much attention to the other languages implemented on the jvm? Like jruby and jython for example?
03:40asbjxrnClojure? I wouldn't think so. If you mean Rich Hickey (The developer), I don't know. I would assume he has had a look.
03:41asbjxrnIf you mean clojure, in what way do you mean "pay attention"?
07:54asbjxrnIs it possible to do something like (unbound? variable) (Or, how do I test if a symbol is bound?)
07:55asbjxrn(Without triggering an exception...)
07:58asbjxrnOh, and one can simulate around methods by binding a function, is it possible to do the same with evaluation of a variable? (I'd like to lookup if a symbol is in a map, and if it is not pass the symbol on to clojures own variable evaluator(?)
07:59rhickey(.isBound #'rest)
08:00asbjxrn#' is shortcut for resolve, I take it?
08:00rhickeyno, for var
08:01asbjxrnok.
08:01rhickeythere's no way to put code in the path of finding the value of a var (your second question)
08:02rhickeythe only reason you get different behavior when binding a fn is because it gets called
08:04asbjxrnI was hoping there were some kind of lookup function that could have been rebound, but I guess something like that would have too much of an impact on performance.
08:04rhickeyexactly
08:06asbjxrnCan one say it would turn clojure into a interpreter pretty much(?) (Which is what I've almost ended up with in an attempt to implement the functionality myself.)
08:07rhickeyeven interpreters that do lookup often hardwire that
08:14asbjxrnI think I finally had a glimpse of understanding of vars and binding. Made a lot of my existing code unnecessary by having a unbound var globally and binding it in the rendering thread. Really cool. I think I might do that for the rest of the vars as well. (Since the lookup thing isn't possible/desirable)
08:14rhickeyan unbound global var is a beautiful thing
08:15rhickey(because it does thread-locaility enforcement)
08:15rhickeylocality
08:22asbjxrnI made a number function (number from to step) (number 1 6 2) -> [1 3 5] for use as for like this: (doseq i (numbers 1 6 2) (println i))
08:23asbjxrnDid I overlook some builtin functitonality?
08:23rhickeyuser=> (range 1 6 2)
08:23rhickey(1 3 5)
08:23asbjxrnright.
08:23asbjxrnIt felt like it might be in there somewhere :)
08:58rhickeyalbino: you had a question about Clojure and other languages on the JVM?
12:46cgrandyet another html templating lib: http://code.google.com/p/clj-stuff/wiki/TemplatingExamples
12:49la_merI've *never* liked sexpr-based templating libs...
13:45rhickeycgrand: cool!
21:13rhickeyClojure gets some serious vectors-of-primitives mojo:
21:13rhickeyuser=> (def pix (float/vec (for [x (range 512) y (range 512)] (+ x y))))
21:13rhickey#'user/pix
21:13rhickeyuser=> (time (dotimes x 10 (float/vmean pix)))
21:13rhickey"Elapsed time: 8.78 msecs"
21:16rhickeyvec vmap v+n v-n v|n v*n n|v v*n+v v*n-v v*n+n v*n-n vabs vnegateabs vnegate vsqr vsignedsqr vreverse vrunningsum vsort vmax vmin vmean vrms vsum vclip vclipcounts vthresh vdot v== v+v v-v v*v v|v vmaxv vminv v+v*v v-v*v v+v*n v-v*n v*v+n
22:09Chousernice!
22:12Chouserdid you have to re-implement each of those functions for each type of number?
22:12rhickeyyup
22:13rhickeybut it's a one-time thing, the reuse will be high, and no more loops for most jobs
22:14rhickeyIt's modeled on Apple's vDSP lib I use for my audio stuff
22:21Chouseris float/vec different from a Java array of floats?
22:22rhickeyno - it is a Java array of floats
22:22rhickeycould be called array instead