Bug report -- macros within let [Re: Bizarre behavior (bug?) for unchecked-add]

2009-04-24 Thread ke...@ksvanhorn.com
I have more information on this now, and it is definitely a bug in Clojure -- defmacro within a let doesn't work correctly. Consider the following file: --- BEGIN foo1a.coj --- (ns com.ksvanhorn.foo1a) (let [dummy 0] (defmacro add [ args] `(unchecked-add ~...@args)) (defmacro mul [ args]

Re: Bit-Shift without Sign-Extend?

2009-05-23 Thread ke...@ksvanhorn.com
Here's how I implemented the operator for ints: (let [intmask (dec (bit-shift-left 1 32))] (defmacro ushr [x n] `(int (bit-shift-right (bit-and ~intmask ~x) ~n The (bit-and intmask x) expression effectively gives you the unsigned equivalent of x. For bytes, use 255 instead of intmask.