On 16.01.2009, at 00:04, Daniel Jomphe wrote:

> When I found that out, I was surprised. My knowledge of lisp comes
> from reading, in the past few months:
> - ANSI Common Lisp
> - Practical Common Lisp
> and, some years ago, a few more things.

The best book to read about macros is in my opinion Paul Graham's "On  
Lisp", which is now available for free download:

        http://www.paulgraham.com/onlisp.html

It covers mostly Common Lisp plus a bit of Scheme, but many of the  
ideas carry over very well to Clojure.

> Even now that I hurt myself against this limitation, I'm still to make
> complete sense out of it. I understand that macros aren't known to
> functions because functions only get to see their expansions, but it's
> fuzzy in my mind how some functions interact well with macros while
> some others don't.

The fundamental restriction is that you cannot pass macros to  
arguments as functions, and that is exactly what would be required to  
do a reduce over and. The universal workaround is to define a  
function that contains nothing but the macro, such as

        (fn [x y] (and x y))

which can also be written in Clojure using the shorthand notation

        #(and %1 %2)

Here the macro gets expanded inside the function *body*, but what you  
pass around is the function *object*.

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