On Thu, Sep 9, 2010 at 10:04 AM, ajuc <aju...@gmail.com> wrote:
>
>
> On 9 Wrz, 14:25, Andrew Gwozdziewycz <apg...@gmail.com> wrote:
>> The fact that Lisp macros actually operate on the AST means that Lisp
>> macros can make *changes* to the AST (insert things, remove things,
>> rearrange things), and *not* just substitute FOO for BAR. This is a
>> hell of a lot more powerful.
>>
>> --http://www.apgwoz.com
>
> To be fair to C and C++ they allow changing AST:
>
> #define UNLESS(x,y) {if (!(x)) {y;} };
>
> This macro changes (UNLESS x y) to (if (not x) y) - this is different
> AST trees.
>
> The only difference I see is that in C you have to work with
> characters, when in lisp you work with lists, and that in C you can
> only use preprocessor directives at compile time (you can't output
> diffrent code in macro depending on the structure of its arguments),
> when in lisp you can use lisp at compile time to change what code will
> be created by macro.

Well, C preprocessor macros don't really *change* the AST, it
*affects* the source *before* it's passed to the compiler (the
compiler creates the AST). You've also stumbled on the most important
difference between the two types--those differences make Lisp style
macros far more powerful.

-- 
http://www.apgwoz.com

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