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

Free variables in a LAMBDA which names a function



    (defun foo (arg)
      ((lambda (x) (+ x arg)) 5))

    I would expect:

    (setf arg 16)
    (foo 3) ==> 8

That is correct. `arg' is lexically scoped. Except for declaration handling
you can treat an expression with a lambda, of a fixed number of arguments,
in the functional position as if it were the obvious expansion of a let
expression (or vice versa). Declarations (especially special declarations)
screw up this simple model however.