Characters allowed in symbols

2009-03-27 Thread ke...@ksvanhorn.com
The Clojure documentation, under "Reader", gives a list of characters allowed in a symbol name. The characters, <, >, and = are not included in this list. How is it then that <, <=, >, >=, =, etc. are symbols? (I assume they are symbols because I can write (< 3 4), etc.) --~--~-~--~---

Using method names in macros

2009-03-28 Thread ke...@ksvanhorn.com
I'm in the process of learning Clojure, and I ran across something that other newbies like me may find useful. The question I had was this: how does one get a method name into a macro? Consider the following code: (defmacro foo [x] `(. Character (isWhitespace ~x))) Yes, I know that this woul

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

2009-04-23 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 intmas