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

Named lambdas



Yes, the name in named-lambda is just machine-readable commentary -- the
evaluator just ignores it.

(defun foo (a b c) ...)

puts

(NAMED-LAMBDA FOO (A B C) ...)

into the symbol-function slot of the symbol FOO, instead of the more
traditional

(LAMBDA (A B C) ...)

When the DEFUN gets compiled, the name is hidden in the compiled
function object, so similar debugging information is available.  In the
Spice Lisp implementation, at least, the LAMBDA form is on the stack,
but not the calling form, so it would be awkward (not impossible) to
recover the function name for debugging; the NAMED-LAMBDA hack solves
the problem.  This is something of a kludge, and I have no strong
opinion about whether it should be in the white pages or whether we
should just quietly do our dirty hacking behind the scenes.  The only
problem is that users might see named-lambdas on the stack and wonder
what is up, so they at least have to be documented in the red pages of
implementations that use this trick.

-- Scott