help-gnu-emacs
[Top][All Lists]
Advanced

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

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


From: Pascal J. Bourguignon
Subject: Re: Is it possible for a macro to expand to nothing?
Date: Sun, 29 Nov 2009 01:54:26 +0100
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (darwin)

Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:

> pjb@informatimago.com (Pascal J. Bourguignon) writes:
>
>> Alan Mackenzie <acm@muc.de> writes:
>>
>>> Pascal J. Bourguignon <pjb@informatimago.com> wrote:
>>>> Tim X <timx@nospam.dev.null> 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.
>>
>> Yes, emacs lisp is missing reader macros.  In Common Lisp there's #+,
>> #- and #., and reader macros may return 0 object.
>
> A little note about #., it have emacs equivalent `eval-when-compile':

But #. is not eval when compile, it's eval when reading!
Compilation occurs much later after reading...

'#.(+ 1 2) --> 3

The result 3 is computed when reading the quote form.  
What is read is (quote 3):  

(read-from-string "'#.(+ 1 2)") --> (quote 3) ; 10



> I don't know the #- and #+ macros, what are they for?

   #+KEY THING

is equivalent to cpp:

    #ifdef KEY
    THING
    #endif

only it's not textual. #- <=> #ifndef


What is tested is the presence of the keyword :KEY in the *FEATURES* list.

(when (zerop (random 2)) (push :test *features*))
'(#+test present #-test absent) --> (present) or (absent)


-- 
__Pascal Bourguignon__


reply via email to

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