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

Function cells



For the "usual case" it is perfectly reasonable to have separate
function and value cells--I make use of that feature all the time.
But the situation changes when you start to pass functions around in
value cells.  The awkward convention of specifying a function call by

  (FUNCALL fun arg1 arg2 ...)   ;where the function is found in the
				;value cell of FUN
rather than

  (fun arg1 arg2 ...)		;in the usual case

is perpetuated by having both a function cell and a value cell.  In
languages which do not adopt this convention (such as Gerry Sussman
and Guy Steele's Scheme) it is possible to use the latter form in
every case, even when FUN has been passed as an argument.  Thus

  (define (foo fn a b)          ;(The slight difference in the syntax
    (fn (* 2 a) b))		;of FOO's function spec is incidental)

replaces

  (defun foo (fn a b)
    (funcall fn (* 2 a) b))

I realize that the deep binding scheme in early Lisp implementations
made it necessary to have a separate mechanism for fast function
lookup, and that the namespace limitation of dynamic scoping makes
having a function context and a variable context handy, but I do not
think that the function/value dichotomy should continue into the
lexically scoped Common Lisp.  In the case where a variable contains a
function (in its value cell) I see little semantic distinction between
the lookup of variables and functions.  In this respect, I fail to see
your point about "separating out mechanisms."  I see it justifiable
only for efficiency reasons and for coping with a limited namespace.

                                 Tim McNerney