[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Defun inside Let
Date: Thu, 30 Jan 86 17:05:05 EST
From: Jonathan A Rees <JAR@MC.LCS.MIT.EDU>
Date: Thu, 30 Jan 86 16:08 EST
From: David C. Plummer <DCP at SCRC-QUABBIN.ARPA>
The questions you raise are valid and important ones, but I don't see
what they have to do with DEFUN. They apply equally to SETQ, SETF,
FLET, LABELS, etc., and are bound to arise the minute you have lexical
closures at all. Yes, it would be nice to be able to update the code
for a closure, alter environments, and so forth, for debugging. But I
don't see why debugging questions should enter into this semantic
question. Is there some reason that DEFUN is different?
Yes, it defines a name in the global environment. This means the user
can talk about a particular DEFUN. A user can't talk about a particular
SETQ or a particular FLET in this way, because they don't have names.
I think calling this "debugging" is ducking a genuine issue of language
definition. "Making DEFUN inside of LET work" is not as simple as some
people seem to think, because the definition of what it means to "work"
is not simple and involves issues like the ones DCP raised, which have
been raised many times before and are probably the reason for the paragraph
on page 66 that everyone likes to dump on.
If there's a
problem with making (DEFUN FOO ...) mean the same [except with respect
to debugging, which Common Lisp doesn't address anyhow] as (SETF
(SYMBOL-FUNCTION 'FOO) #'(LAMBDA ...)), why isn't that problem also a
problem with the SETF form?
Who says it isn't? The only difference is that users aren't accustomed to
writing (SETF (SYMBOL-FUNCTION 'FOO) #'(LAMBDA ...)) all the time.
Let me put it this way. It's easy enough to say that (LET ... (DEFUN FOO ...))
has the same effect as (LET ... (SETF (SYMBOL-FUNCTION 'FOO) #'(LAMBDA ...))),
and in fact I know of no implementation where that is not already true.
The problem comes when people try to use this to do real work. It
quickly becomes apparent that you have actually added a whole new
feature to the language, without much thought or standardization of how
it is to be used.