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

Named lambdas



Named-Lambda was invented by the Lisp Machine folk (I think).  The
syntax is

(NAMED-LAMBDA name arglist . body)

This works in all respects like a lambda, with the name being ignored.
The name is there solely for debugging.  The reason this exists is that
interpreted DEFUN can now put the named-lambda form in the function slot
of a symbol, with the name indicating the name of the function as seen
by DEFUN.  (I guess now this is a function-spec.)  No attempt is made to
keep this up to date if the form is passed around to other places.  At
various times in the interpreter, only the lambda or named-lambda form
is on the stack, and if it is a named-lambda, the debugger can say
something intelligent about what the function is.  In some
implementations, at least, it is very hard to recover the name of the
function in any other way -- it does not appear on the stack in any
meaningful form.  Assorted other code-browsing functions may also find
the name useful.

Since the name is just commentary, and doesn't really do anything, I
don't think that the scoping issues apply.  I'm not really sure whether
lambdas created inside a LABELS or some such would be named -- this
would be used so rarely that I don't really care.  The point is to do
something useful for the normal case of a DEFUN.

-- Scott