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

NAMED-LAMBDA



This is ok with me, but I would like to clarify some things about it.

Fahlman has said twice that you put (NAMED-LAMBDA name args . body) in
the function cell of symbols.  That may be true on the LispM or PERQ,
but on a conventional architecture I'd never put anything but a compiled
function pointer in the function cell in order to keep function calling
fast. Instead, I'd have interpreted DEFUN create a tiny compiled transfer
function to an EVAL entrypoint with the lambda expression as an
argument.  And actually it wouldn't be DEFUN that did this: the compiled
transfer function would be the result of evaluating a LAMBDA or
NAMED-LAMBDA.  This is actually a good argument against allowing
(APPLY '(LAMBDA ...) ...) since that implies that
(SETF (SYMBOL-FUNCTION-VALUE 'F) '(LAMBDA ...)) will work.  I'd be very
upset if Common-Lisp tried to force that on an implementation.  For
efficiency on a conventional architecure, I'd also make all functions be
closures, i.e. have a lexical environment, even if it is ().  That's
another reason not to put lambda forms into function cells.

Thus, on conventional machines, users would almost never see
NAMED-LAMBDAs.  The name for debugging would be presumably be retreived
from this compiled transfer function.  The only use of NAMED-LAMBDA is
as a way for DEFUN to communicate the name to whatever creates the
transfer code.