On Fri, Sep 25, 2009 at 4:49 PM, Constantine Vetoshev <[email protected]>wrote:
> (let [f1 #(inc %)]
> (defmacro m1 [x]
> `(~f1 ~x)))
>
> (m1 12)
> => No message.
> [Thrown class java.lang.ExceptionInInitializerError]
>
> The equivalent works in Common Lisp (Allegro CL and SBCL):
>
> (let ((f1 (lambda (y) (1+ y))))
> (defmacro m1 (x)
> `(funcall ,f1 ,x)))
>
> (m1 12)
> => 13
>
> Thoughts on either of these brain teasers?
I don't think you can use things like defmacro in a let. Macros are used at
macroexpansion time and I don't think a let's bindings will exist yet. So
you probably need something like
(defmacro m1 [x]
(let [f1 #(inc %)]
`(~f1 ~x)))
instead.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---