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

Symbols as functions



Technical, not administrative:

We've had a bit of a debate here about whether it is legal, according
the the current manual, to use a symbol as the Symbol-Function of
another symbol.  (It is clear that you can pass a symbol as the function
to Apply and that (functionp <some symbol>) is true.)  In other words,
if I do

(defun foo () 'barph)
(setf (symbol-function 'foo1) 'foo)
(setf (symbol-function 'foo2) 'foo1)
(foo2)

must the system return BARPH, or is it allowed to barf?  The issue comes
up because CommonLoops happens to do something like this and Spice Lisp
doesn't support it at present.

Long ago this was explicitly forbidden in Spice Lisp because it slowed
things down and an infinitely loop of symbols calling each other was
very hard to check for.  Later Guy realized that the old trick of using
two pointers, one moving at half speed, would detect such loops, and the
inefficiency would only show up if you actually used such chains. SO he
wanted to lift this restriction; I didn't, because I thought it was a
worthless crock, and this never got changed in Spice Lisp (and
presumably many of its progeny).  The language in the book about symbols
being legitimate functions comes from a completely different debate, the
one about whether it is OK to say (apply 'foo ...) instead of (apply
#'foo ...).

Anyway, I thought I'd see if the rest of you have some clear impression
of what is currently required and/or what should be, before throwing
this open to comment from the entire mailing list.

-- Scott