Hello, just a follow up: I discovered that I sent the macro def twice and than applied the macro. If the first time the defmacro is evaluated then the resulting macro works as I expected. But when I send the same defmacro a second time to the interpreter, the macro behaves as described below. Can somebody explain why?
Regards Poul synphonix schrieb: > Hello and happy new year, > > I've started this year with playing around with clojure macros and > wrote a macro that > behaves in a way I don't understand: > > (defmacro foo > ([x] `(list ~x ~x)) > ([x n] (if (<= n 0) > `(foo ~x) > `(foo ~(foo x) > ~(- n 1))))) > > (foo :a 0) => (:a :a) ;; What I expected > (foo :a 1) => nil ;; Here I would expect (foo (foo :a) 0) => (foo > (list :a :a) 0) => '((:a :a) (:a :a)) > (foo :a 2) => java.lang.NullPointerException > > Could someone please explain where my understanding of clojure macros > is flawed ? > > Regards > Poul --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---