On 03.06.2010, at 10:36, alux wrote:

> 1. I can use syntax-quote in the REPL, outside of a macro-definition.
> Is this of any use? Does this mean the REPL always macroexpands
> everything?

Macro expansion is part of evaluation, whether at the REPL or elsewhere.

Syntax quote is not macro expansion. It is a shorhand to write code that, when 
executed, returns a specific form. It is more frequently used in macro 
definitions, but you can use it anywhere. You can even look at the code it 
generates:

Clojure> '`(foo (bar ~a) ~b)
(clojure.core/seq (clojure.core/concat (clojure.core/list (quote 
clojure.core/foo)) (clojure.core/list (clojure.core/seq (clojure.core/concat 
(clojure.core/list (quote clojure.core/bar)) (clojure.core/list a)))) 
(clojure.core/list b)))

> 2. maxroexpand and macroexpand-1 dont extend macros in subforms. Is
> there anything that does?

clojure.contrib.macro-utils/mexpandall

> 3. Is there a way to use macros in higher order functions? Say along
> the lines of
> 
> (map def [a b c] [1 2 3])

No. Macros are not functions. BTW, def is a special form, not a macro. But 
neither can be passed as a function.

What you can do, however, is this:

Clojure> (map (fn [s v]  `(def ~s ~v)) '(a b c) '(1 2 3))
((def a 1) (def b 2) (def c 3))

Add a "do" in front, and you can pass it to eval:

(eval (cons 'do (map (fn [s v]  `(def ~s ~v)) '(a b c) '(1 2 3))))

> Btw, am I right that this might be possible in a lazy language?

It's not impossible to imagine such a language, but I don't know of any.

Konrad.

-- 
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