[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lexical scoping rule
- To: INFO-MCL@CAMBRIDGE.APPLE.COM
- Subject: lexical scoping rule
- From: GRAME@AppleLink.Apple.COM (France - Grame, Lyon,IDV)
- Date: 08 Apr 92 09:09 GMT
The lexical scoping rule seems to have strange behaviours in MCL2.0 (or may be
it's Common Lisp).
The first example is ok :
? (defun compose (x y) #'(lambda (n) (funcall x (funcall y n))))
COMPOSE
? (funcall (compose #'sqrt #'abs) -9)
3
But now :
? (defvar x 13)
X
? (defun compose (x y) #'(lambda (n) (funcall x (funcall y n))))
COMPOSE
? (funcall (compose #'sqrt #'abs) -9)
> Error: 13 can't be FUNCALLed or APPLYed.
> While executing: CCL::TOPLEVEL-EVAL
> Type Command-. to abort.
See the Restarts... menu item for further choices.
Because of the DEFVAR, the X variable is no more part of the closure of the
lambda-expression.
It seems to me to be a bug because the X variable visible to the
lambda-expression is lexically scoped.
-Yann-