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] `(unchecked-multiply ~...@args))
  (let [magic 1812433253
                x 5489
                v (add 1 (mul magic x))]
          (println (str "v: " v))))
--- END ---

If I type "(use 'com.ksvanhorn.foo1a)" at the REPL, I get

  v: (clojure.core/unchecked-add 1 (clojure.core/unchecked-multiply
1812433253 5489))

printed out and nil returned, but if I just type

  (uncheck-add 1 (unchecked-multiply 1812433253 5489))

I get 1301868182.

Although in this case the defmacro doesn't need to be inside the let,
I actually have a real need for doing defmacro inside a let -- I have
a computed constant that I want to use in several places, and one of
those places is in the macro definition.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to