On Fri, Jun 26, 2009 at 9:22 AM, Michele
Simionato<michele.simion...@gmail.com> wrote:
>
> On Jun 26, 9:53 am, Michele Simionato <michele.simion...@gmail.com>
> wrote:
>>  I want to asset the status of Clojure
>> macros with respect to hygiene.
>
> Some further experiment:
>
> $ clj
> Clojure 1.1.0-alpha-SNAPSHOT
> user=> (def x 42)
> #'user/x
> user=> (defmacro m[] 'x)
> #'user/m
> user=> (m)
> 42
> user=> (let [x 43] (m))
> 43
>
> There is no referential transparency, it seems.

How not?

> Also, it looks like
> Clojure macros are runtime macros,
> i.e. they may depend from runtime values and macro expansion cannot be
> performed statically
> without running the program (which is usually considered pretty bad).
> Am I correct?

No. Please use macroexpand in order to facilitate yourunderstanding.
By using quote, and not syntax-quote, you have written an
intentionally capturing macro:

user=> (def x 42)
#'user/x
user=> (defmacro m[] 'x)
#'user/m
user=> (macroexpand '(m))
x
user=> (let [x 43] (m)) ;i.e. (let [x 43] x)
43

The correct way is to use syntax-quote:

user=> (defmacro m[] `x)
#'user/m
user=> (macroexpand '(m))
user/x
user=> (let [x 43] (m)) ;i.e. (let [x 43] user/x)
42

> Finally, as an unrelated question, is there an equivalent of macrolet
> in Clojure?

Not yet.

Rich

--~--~---------~--~----~------------~-------~--~----~
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
Note that posts from new members are moderated - please be patient with your 
first post.
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