[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Defun inside Let
Date: Thu, 30 Jan 1986 14:29 EST
From: "Scott E. Fahlman" <Fahlman@C.CS.CMU.EDU>
There can be no question at all on the point Jeff Dalton raises: when a
Defun occurs inside a Let or anywhere else, it changes the GLOBAL
function definition for the symbol in question. It is not a form of
LABELS.
We've discussed this inside Symbolics, and we don't have a solution for
the following problem:
(let ((a 3)
(b 5))
(defun add-and-increment ()
(prog1 (+ a b)
(incf a)
(incf b)))
(defun sub-and-decrement ()
(prog1 (- a b)
(decf a)
(decf b))))
That's all fine and dandy. Now come the hard parts.
- What if I want to redefine add-and-increment to be
(defun add-and-increment (&optional amount)
(prog1 (+ a b)
(incf a amount)
(incf b amount)))
Is the system expected to know that >the old version< of
add-and-increment is a lexical closure over some variables and make the
new one share that same environment?
- What if I wanted to add a variable to the lexical environment? What
forms to I type to splice something in?
- What if I want to redefine add-and-increment to be interpreted? Are you
forcing all implementations to have the same compiler and interpreter
environment?
- Suppose you declare 'you are not allowed to redefine a function whose
old definition is closed over a non-null lexical environment and
expect it to inherit the old environment.' What if I interpret the
above LET. Am I allowed to compile just one of the functions? If
not, why not? If not, am I allowed to compile both? If so, how do I
manage that with the tools provided (which presumably compile on
thing at a time.) If I am allowed to compile just one, does that
enforce the same format for compiled and interpreted lexical
environments?
I don't have answers for any of those. It's not clear to me there ARE
answers to some of them. What if somebody on the ISO board thinks up
roughly the same questions? If somebody does have >answers<, I'd like
to hear them. My personal feeling is that DEFUN that requires a
non-null lexical environment, such as created by LET, is a timebomb
ticking quickly.