#clojure log - May 27 2008

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

3:33 albino: Does clojure pay much attention to the other languages implemented on the jvm? Like jruby and jython for example?

3:40 asbjxrn: Clojure? I wouldn't think so. If you mean Rich Hickey (The developer), I don't know. I would assume he has had a look.

3:41 If you mean clojure, in what way do you mean "pay attention"?

7:54 Is it possible to do something like (unbound? variable) (Or, how do I test if a symbol is bound?)

7:55 (Without triggering an exception...)

7:58 Oh, 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(?)

7:59 rhickey: (.isBound #'rest)

8:00 asbjxrn: #' is shortcut for resolve, I take it?

8:00 rhickey: no, for var

8:01 asbjxrn: ok.

8:01 rhickey: there's no way to put code in the path of finding the value of a var (your second question)

8:02 the only reason you get different behavior when binding a fn is because it gets called

8:04 asbjxrn: I 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.

8:04 rhickey: exactly

8:06 asbjxrn: Can 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.)

8:07 rhickey: even interpreters that do lookup often hardwire that

8:14 asbjxrn: I 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)

8:14 rhickey: an unbound global var is a beautiful thing

8:15 (because it does thread-locaility enforcement)

8:15 locality

8:22 asbjxrn: I 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))

8:23 Did I overlook some builtin functitonality?

8:23 rhickey: user=> (range 1 6 2)

8:23 (1 3 5)

8:23 asbjxrn: right.

8:23 It felt like it might be in there somewhere :)

8:58 rhickey: albino: you had a question about Clojure and other languages on the JVM?

12:46 cgrand: yet another html templating lib: http://code.google.com/p/clj-stuff/wiki/TemplatingExamples

12:49 la_mer: I've *never* liked sexpr-based templating libs...

13:45 rhickey: cgrand: cool!

21:13 Clojure gets some serious vectors-of-primitives mojo:

21:13 user=> (def pix (float/vec (for [x (range 512) y (range 512)] (+ x y))))

21:13 #'user/pix

21:13 user=> (time (dotimes x 10 (float/vmean pix)))

21:13 "Elapsed time: 8.78 msecs"

21:16 vec 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:09 Chouser: nice!

22:12 did you have to re-implement each of those functions for each type of number?

22:12 rhickey: yup

22:13 but it's a one-time thing, the reuse will be high, and no more loops for most jobs

22:13 * Chouser nods

22:14 rhickey: It's modeled on Apple's vDSP lib I use for my audio stuff

22:21 Chouser: is float/vec different from a Java array of floats?

22:22 rhickey: no - it is a Java array of floats

22:22 could be called array instead

Logging service provided by n01se.net