[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: issue DEFINING-MACROS-NON-TOP-LEVEL (Version 4)
- To: Kent M Pitman <KMP@scrc-stony-brook.arpa>, sandra <@cs.utah.edu:sandra@defun>
- Subject: Re: issue DEFINING-MACROS-NON-TOP-LEVEL (Version 4)
- From: Jeff Dalton <jeff%aiai.edinburgh.ac.uk@NSS.Cs.Ucl.AC.UK>
- Date: Tue, 27 Sep 88 16:45:48 BST
- Cc: firstname.lastname@example.org
- In-reply-to: Kent M Pitman's message of Sun, 25 Sep 88 16:58 EDT
Kent -- according to my mailer here, your message went to X3J13
instead of Cl-Compiler.
> Since this proposal is apparently (although not explicitly) dependent on
> your EVAL-WHEN-NON-TOP-LEVEL:CLARIFY, and since I don't support that
> proposal, it shouldn't come as a surprise that I can't support this one.
> * For the most part, it doesn't make any sense to do
> (DEFUN ... (DEFUN ...)) so it seems strange to encourage it.
> The only practical reason I can think of for doing this is to do
> some sort of module facility where you selectively activate definitions
> that you need by calling the outer function. I think this is what
> LOAD and packages are already in CL for, and although I don't think they
> are the answer to all the world's problems, they are better than
> doing nested defuns.
While it is true that (DEFUN ... (DEFUN ...)) is strange, and doesn't
do anything that anyone is likely to want (i.e., selectively activate
definitions), DEFUN inside LET, FLET, or LABELS is less strange and is
(I think) useful. Indeed, page 67 says what DEFUN means in non-null
[LABLES inside DEFUN defines one global function with several locals;
DEFUN inside LABELS defines more than one global function with the
same locals. I'm inclined to think that if the first is reasonable
the second is too.]
Of course, you might define "top level" to mean "not inside a defining
form". That would more or less rule out the cases you dislike while
leaving the more useful ones.
But there would still be a consistency problem, namely that macros
and functions can be defined inside defining forms by doing a SETF
of SYMBOL-FUNCTION or MACRO-FUNCTION. So the question is: why let
people do this only "by hand"? Why not let them use DEFUN and friends?
BTW, one reason to do a DEFUN inside a DEFUN is to get a DEFUN inside
some other forms and make sure the whole thing is compiled properly.
The outer DEFUN is then called once to set everything up. If
implementations could be relied on to take non-top-level DEFUN
seriously (i.e., if the 2nd paragraph of section 5.2 (page 66)
were changed), this peculiar technique would probably vanish
from the world.
> * The Scheme language attaches a very different meaning to
> (DEFUN FOO (X)
> (DEFUN BAR (X) ...) ... (BAR ...) ...)
True. Interesting enough, I asked the CL list about this a few
years ago. I wondered why CL didn't do the same thing as Scheme.
(After all, most languages that allow local procedures use the
same defining syntax that they do for top-level procedures.)
The answer was that DEFUN (to define a global function) inside
LET was useful, much used, etc.
> I would prefer that defining forms just be restricted to toplevel
> because we don't have time in the next three months to do any better
> than that.
Well, for DEFUN we can favor page 67 over page 66. That conflict
should be resolved in any case.
That's how we got into this, isn't it? Fix DEFUN. Then: why not