[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
What can I redefine?
- To: Common-Lisp@SU-AI.ARPA
- Subject: What can I redefine?
- From: Pavel.pa@Xerox.COM
- Date: Mon, 7 Apr 86 15:15:37 PST
Consider the following code:
(defun bar (y) (* y 2))
(defun foo (x) (+ (bar x) 1))
(defun bar (y) (* y 3))
I think (hope) that everyone would agree that the final function call
returns 22. That is, it is expected that the compiler will not make use
of the current definition of ``bar'' in generating code for ``foo''.
But what about this case:
(defun foo (x) (+ (car x) 1))
(defun car (y) (* y 3))
Surely every compiler in the world will open-code ``car'' without asking
permission from the user. Thus this code should produce an error (or is
at least has undefined effect under the standard). Is this considered
``correct'' behavior for the compiler? Is its behavior expected to be
any different if the redefinition of ``car'' occurs before the
compilation? That is, is the compiler supposed to check for the
redefinition of constructs about which it has special knowledge?
Do any of these answers change if I replace ``car'' by ``disassemble''
in the above example? The idea is that one might be surprised to find a
compiler with special knowledge of the ``disassemble'' function and so
perhaps one should be allowed to count on calls to it not being
The silver book is, so far as I've seen, fairly silent on the issue of
what things the user is allowed to redefine. The only reference I've
found is this, from page 67:
``It is an error to attempt to redefine the name of a special form.''
I would like to see a statement in the standard that
``It is an error to attempt to redefine the name of any
function, macro, or special form defined in this standard.''
Otherwise, I'll feel like I'm cheating if I use any special knowledge in
my compiler without first checking somehow to be sure that no
redefinition has taken place.