Barry Margolin <barmar@alum.mit.edu> wrote:
+---------------
| "Karol Skocik" <Karol.Skocik@gmail.com> 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~:^, ~}.~%"
',where
,@(loop for form in forms collect
`(list ',form ,form))))
SHOW
> (defvar a 12)
A
> (defun a () a)
A
> (let ((b 34))
(flet ((b () b))
(show (before) a (a) b (b))
(funcall (lambda (a b)
(show (lambda) a (a) b (b)))
56
78)
(show (after) a (a) b (b))
nil))
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.
NIL
>
[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.]
-Rob
[1] For example: (LET ((*PACKAGE* XYZ-PKG)) (READ)).
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607