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

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

RE: About `defun' in elisp manual


From: Drew Adams
Subject: RE: About `defun' in elisp manual
Date: Fri, 28 Dec 2012 07:35:37 -0800

> Above, BODY-FORM must be a proper list therefore the lambda expression
> is a proper list.

While correct and providing the info needed for understanding, I'm not sure that
the explanation given so far will directly bridge Fuqiao's misunderstanding.

The first thing is the typo: it is BODY-FORMS, not BODY-FORM, and that is an
important clue.

The point is that a lambda expression does not *require one* sexp (a list or an
atom) after ARGUMENT-LIST - it accepts any number of sexps, including zero.

BODY-FORMS is a list here - a list of body forms, which themselves are often
lists.  If a lambda expression accepted only one list as its body then removing
the dot for the syntax would be correct.

BODY-FORMS has zero or more elements.  By using the dot, the syntax indicates
that the list is *spliced into* the lambda expression, instead of simply
appearing as a single list sexp.

IOW, each of its elements is a body form, and they are what appear directly in
the lambda expression.  If BODY-FORMS is ((foo bar)) then there is a single body
form, (foo bar), and the sexp is (lambda ARGUMENT-LIST (foo bar)).  If
BODY-FORMS is (foo bar) then there are two body forms, foo and bar, and the sexp
is (lambda ARGUMENT-LIST foo bar).

Now go back and read what Pascal and Florian wrote, explaining that lists are
really dotted lists.

As Pascal said, BODY-FORMS is a *proper* list, that is, a dotted list with () as
its final cdr.

If BODY-FORMS is (X Y Z) then (A . BODY-FORM) is (A X Y Z), that is,
(A . (X . (Y . (Z . nil))))


[Be aware that sometimes the Emacs doc writes "BODY-FORMS..." instead of ".
BODY-FORMS".  And it might not be clear to some readers whether that means one
or more or zero or more sexps.  In most contexts other than Emacs, "A..." stands
for a single A followed possibly by additional As: one or more repetitions of A.

But in Emacs doc the "..." seems to stand for zero or more, not one or more, and
the Emacs doc writes "BODY-FORMS..." (plural and with repetitions), not
"BODY-FORM...".  Sometimes it writes "BODY..." (singular) and then in the text
refers to BODY in the plural: "forms".  (Also, sometimes there is a space before
"...", sometimes not.)

The syntax used in the description of a lambda expression is simpler and has no
such ambiguity and sending of mixed signals - it is Lisp syntax!]




reply via email to

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