Bizarre behavior (bug?) for unchecked-add

2009-04-24 Thread Kevin Van Horn
When unchecked-add is given an invalid argument, sometimes it throws an exception, and sometimes it does something very weird -- it returns the code for the call! Referring to the files foo1.clj and foo2.clj below, if I type at the REPL (use 'com.ksvanhorn.foo2) I get

Bit-level operations

2009-04-23 Thread Kevin Van Horn
I'm writing an application that needs fast, high-quality random number generation, so I've been implementing a Mersenne Twister random number generator. I'm finding that bit-twiddling in Clojure can be a bit awkward. Here are some specifics: 1. bit-and, bit-or, and bit-xor only take two

Interaction of macros and special forms

2009-04-01 Thread Kevin Van Horn
I've been going through Stuart Halloway's book, _Programming Clojure_, and thinking about his deftarget macro has brought up some questions as to how macros and special forms interact in clojure. The deftarget macro needs to produce a def form that has metadata on its first argument,