Subject: Re: sharp-quoting special functions
From: rpw3@rpw3.org (Rob Warnock)
Date: Fri, 09 Jun 2006 02:55:09 -0500
Newsgroups: comp.lang.lisp
Message-ID: <po2dnaBPGOHAtBTZnZ2dnUVZ_oKdnZ2d@speakeasy.net>
doug <doug_arro@yahoo.com> wrote:
+---------------
| ...is there a simple, not CLHS-ish, explanation on why I am seeing
| different behaviors here?
+---------------

Not really. Any explanation would almost *have* to invoke the CLHS, since
the inclusion of the LAMBDA *macro* [as opposed to the *symbol* LAMBDA]
is one of those things that was added to the ANSI Common Lisp Standard
[which the CLHS mirrors] relatively late in the game, as I understand it.
Compare:

    http://www.lisp.org/HyperSpec/Body/mac_lambda.html

and:

    http://www.lisp.org/HyperSpec/Body/sym_lambda.html

+---------------
| I have to say I am now confused when my lisp implementation, SBCL in
| this case, does not produce the result from the text that I am reading.
|  Another example from the book shows that an unquoted lambda at the
| top-level would produece an error:
| > (lambda (n) (* n 10))
| Error: Undefined function LAMBDA
+---------------

The text that you are reading is not describing ANSI Common Lisp, but
"some other" Lisp. Your example is required to work [that is, give results
similar (see below) to what SBCL did] in a Common Lisp. You can probably
work around this problem by using the example macro definition of LAMBDA
given at the bottom of the first URL above.

+---------------
| But when I tried this in sbcl 0.9.13, I got this:
| CL-USER> (lambda (n) (* n 10))
| #<FUNCTION (LAMBDA (N))  {AD1FD5D}>
+---------------

This[1] is indeed what you should expect from any implementation
that purports to conform with ANSI Common Lisp. It is certainly
what you will get from SBCL, CMUCL, CLISP, Corman Lisp, Allegro
Common Lisp, Lispworks, etc., etc., etc.


-Rob

[1] Modulo implementation variations in PRINT-NOT-READABLE-OBJECT
    and whether or not REPL input is automatically compiled, e.g.,
    CLISP will say #<CLOSURE :LAMBDA (N) (* N 10)> and CMUCL will
    say #<Interpreted Function (LAMBDA (N) (* N 10)) {484D6CE9}>.

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607