[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is it possible for a macro to expand to nothing?

From: Alan Mackenzie
Subject: Re: Is it possible for a macro to expand to nothing?
Date: Sat, 28 Nov 2009 08:29:12 +0000 (UTC)
User-agent: tin/1.6.2-20030910 ("Pabbay") (UNIX) (FreeBSD/4.11-RELEASE (i386))

Pascal J. Bourguignon <address@hidden> wrote:
> Tim X <address@hidden> writes:

>> On the other hand, Alan's arguments also have merit. If a macro can be
>> useful in generating something other than a form that can be
>> evaluated, such as a data structure and can do so in a way that is
>> cleaner/simpler or just easier to understand than doing the same using
>> functions, then it would make sense. His examples from the C modes
>> seem to be a case in point.

> Perhaps Alan's problem with functions comes from the confusion between
> backquote and macros.  Since backquote (and , and ,@) are often used in
> macros, some people believe they can be used only in macros, and that
> they ARE what macros are.

Er, do I actually have a problem with functions?  But no, I don't suffer
that particular confusion between backquotes and macros, and have indeed
used backquote when there hasn't been a macro within zeptoparsecs.

> Far from it!  I don't know any language more orthogonal than lisp.

Maybe not, but even lisp only gets to about 89 degrees.  It is missing an
operator which does the same as ,@ outside backquote.  This is one of the
lacks which makes it so difficult to write an equivalent of C's #if.

> Backquote can be used in a function to build a s-exp (including part of
> a form) as it can be used anywhere.

> Therefore it is really not easier to use macros to generate parts of a
> form than function.

It is if you need "side effects", like c-lang-defconst and friends do.

[ Stuff read and appreciated.  My brain's not up to it so early in the

> If you wanted to use macros, in addition to the complexity of having
> to use macroexpand to use it, you would have the difficulty of passing
> the parameters, since a macro gets it's parameters from the source
> form.  In the case of a function, you have the choice to quote or not
> to quote the parameters, with macros they're always quoted for you.

In the case of a function, you've GOT to quote, which can get very
tedious in some circumstances.  That's probably the reason that Martin
Stjernholm wrote c-lang-const etc. as macros.

Alan Mackenzie (Nuremberg, Germany).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]