[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Common Lisp Semantics for Function Call
- To: cl-cleanup@sail.stanford.edu
- Subject: Common Lisp Semantics for Function Call
- From: Robert S. Boyer <boyer@CLI.COM>
- Date: Mon, 20 Jun 88 09:43:23 CDT
- Cc: yuasa%tutics.tut.junet%utokyo-relay.csnet@RELAY.CS.NET, Masinter.pa@Xerox.COM, wfs@CLI.COM
In the case of an ordinary function call, does Common Lisp specify
whether the symbol-function is grabbed before or after the args are
evaluated? Symbolics and KCL do it "before" when interpreting and
"after" when running compiled code. This question was previously
reported to the Common Lisp mailing list, by Bill Schelter around
December 87 I think, but I saw no response.
It seems to me that the natural solution is to go "before". This
(a) provides an extension of the left-to-right-order of evaluation
that is part of Common Lisp (even if it is not in the manual), and
(b) is consistent with the idea that you need, when interpreting,
to look at the definition of the car of the form to decide
whether it is a macro or not.
Below is an illustration of the problem of "before" vs. "after",
in KCL.
>(defun foo ()
(setf (symbol-function 'bar) #'(lambda (x) (print 'old)))
(bar (setf (symbol-function 'bar) #'(lambda (x) (print 'new)))))
FOO
>(foo)
OLD
OLD
>(foo)
OLD
OLD
>(foo)
OLD
OLD
>(compile 'foo)
FOO
>(foo)
NEW
NEW
>(foo)
NEW
NEW
>(foo)
NEW
NEW
; It is, of course, unnecessary to observe that such coding is
; inelegant, even repulsive.