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: Tue, 24 Nov 2009 01:03:13 +0100
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (darwin)

"Drew Adams" <drew.adams@oracle.com> writes:

>> > Huh? It produces the list ((setq bar 2)), assuming `ifdef' 
>> > acts like `and'
>> 
>> Yes.  And ((setq bar 2)) is not a valid form.
>
> Of course it's valid - it's a list.

I'm using this definition:

  form n. 
    1. any object meant to be evaluated. 
    2. a symbol, a compound form, or a  self-evaluating object. 
    3. (for an operator, as in ``<<operator>> form'') a compound form
    having that operator as its first element. ``A quote form is a
    constant form.''

(eval '((setq bar 2)))
--> Debugger entered--Lisp error: (invalid-function (setq bar 2))

Therefore ((setq bar 2)) is not valid form.


> Perhaps you are trying to _evaluate_ it? 

Yes, that's what the result of macro calls should, at leat
potentially, be done with.


> [And BTW, a sexp whose evaluation raises an error is not necessarily 
> "invalid".
> Validation requires validation against something (e.g. a syntax definition or 
> a
> specification). Lisp _syntax_ can be said to be invalid if it raises a 
> read-time
> error. But just because evaluating a sexp raises an error doesn't mean the
> syntax is invalid. The list (bar) is not "invalid" if evaluating it raises the
> error that bar's function definition is void.]

If that was the case, then in a protected environment like lisp,
everything is valid, as long as we don't stumble upon a crashing bug
in the implementation.

But it is more useful to distinguish forms doing something useful for
the user or programmers from those signaling errors systematically,
because of their intrinsic nature (because they're invalid forms).
 

-- 
__Pascal Bourguignon__


reply via email to

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