2008-05-27
| 03:33 | albino | Does clojure pay much attention to the other languages implemented on the jvm? Like jruby and jython for example? |
| 03: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. |
| 03:41 | asbjxrn | If you mean clojure, in what way do you mean "pay attention"? |
| 07:54 | asbjxrn | Is it possible to do something like (unbound? variable) (Or, how do I test if a symbol is bound?) |
| 07:55 | asbjxrn | (Without triggering an exception...) |
| 07:58 | asbjxrn | 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(?) |
| 07:59 | rhickey | (.isBound #'rest) |
| 08:00 | asbjxrn | #' is shortcut for resolve, I take it? |
| 08:00 | rhickey | no, for var |
| 08:01 | asbjxrn | ok. |
| 08:01 | rhickey | there's no way to put code in the path of finding the value of a var (your second question) |
| 08:02 | rhickey | the only reason you get different behavior when binding a fn is because it gets called |
| 08: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. |
| 08:04 | rhickey | exactly |
| 08: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.) |
| 08:07 | rhickey | even interpreters that do lookup often hardwire that |
| 08: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) |
| 08:14 | rhickey | an unbound global var is a beautiful thing |
| 08:15 | rhickey | (because it does thread-locaility enforcement) |
| 08:15 | rhickey | locality |
| 08: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)) |
| 08:23 | asbjxrn | Did I overlook some builtin functitonality? |
| 08:23 | rhickey | user=> (range 1 6 2) |
| 08:23 | rhickey | (1 3 5) |
| 08:23 | asbjxrn | right. |
| 08:23 | asbjxrn | It felt like it might be in there somewhere :) |
| 08: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 | rhickey | Clojure gets some serious vectors-of-primitives mojo: |
| 21:13 | rhickey | user=> (def pix (float/vec (for [x (range 512) y (range 512)] (+ x y)))) |
| 21:13 | rhickey | #'user/pix |
| 21:13 | rhickey | user=> (time (dotimes x 10 (float/vmean pix))) |
| 21:13 | rhickey | "Elapsed time: 8.78 msecs" |
| 21:16 | rhickey | 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 | Chouser | did you have to re-implement each of those functions for each type of number? |
| 22:12 | rhickey | yup |
| 22:13 | rhickey | but it's a one-time thing, the reuse will be high, and no more loops for most jobs |
| 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 | rhickey | could be called array instead |