Subject: Re: What's wrong with Common Lisp's lambda ?
From: (Rob Warnock)
Date: Fri, 29 Sep 2006 00:31:16 -0500
Newsgroups: comp.lang.lisp
Message-ID: <>
Barry Margolin <> wrote:
|  "Karol Skocik" <> wrote:
| > and in the section "Impact of Logic", I saw this :
| > Scheme, a dialect of Lisp which got lambda right (Guy Steele and Gerald
| > Sussman, 1975; http://www.schemers .org/).
| > I am a happy CL lambda user, and can't find something wrong in CL's
| > lambda...
| > Could some functional guru explain me what they meant?
| Common Lisp adopted some features of Scheme's lambda, so it doesn't have 
| as many problems as earlier dialects of Lisp.  But there are still holes.

Besides the scope-of-control (continuations) issue you mentioned,
below is another, of even greater impact to newbies.

| Although CL has lexical extent for variable bindings...

Well, yes... and no. As you know like the back of your hand, but
Karol might not, CL:LAMBDA does indeed provide lexical scope for
variable bindings which are either new or which shadow previous
lexical bindings, but provides *dynamic* ("special") semantics for
variables which already have lexically-apparent special declarations:

    > (defmacro show ((&optional (where #\space)) &rest forms)
        `(format t "~&~8a~:@{~a = ~s~:^,  ~}.~%"
                   ,@(loop for form in forms collect
                       `(list ',form ,form))))

    > (defvar a 12)

    > (defun a () a)

    > (let ((b 34))
	(flet ((b () b))
	  (show (before) a (a) b (b))
	  (funcall (lambda (a b)
		     (show (lambda) a (a) b (b)))
	  (show (after) a (a) b (b))

    BEFORE  A = 12,  (A) = 12,  B = 34,  (B) = 34.
    LAMBDA  A = 56,  (A) = 56,  B = 78,  (B) = 34.
    AFTER   A = 12,  (A) = 12,  B = 34,  (B) = 34.

[Karol, if it's not obvious, look at the value of (A) in the LAMBDA line.]

Most Schemers consider this to be evil, and think that dynamic bindings
should always be made quite explicit, e.g., by using FLUID-LET or equiv.

On the contrary, CL'ers consider this feature to be extremely useful[1]
albeit dangerously error-prone, fortunately made essentially harmless
by ALWAYS obeying the surrounding-asterisks naming convention for special
variables, e.g., *VAR*. [Ditto the +CONST+ convention for constants.]


[1] For example: (LET ((*PACKAGE* XYZ-PKG)) (READ)).

Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607