[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Defun inside Let

    Date: Thursday, 30 January 1986  16:08-EST
    From: David C. Plummer <DCP at SCRC-QUABBIN.ARPA>
    To:   Scott E. Fahlman <Fahlman>, common-lisp at SU-AI.ARPA
    Re:   Defun inside Let

    That's all fine and dandy.  Now come the hard parts.  

     - What if I want to redefine add-and-increment to be
       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?
No, and for the reson REM says.  The new definition is in the
environment you define it in, which is null in this case.  Common Lisp
doesn't need to be able to redefine functions within an old
environment.  Perhaps a useful feature, but certainly not necessary to
make good use of definitions in non null-environments.  This is more
of a programming environment issue than a lexical environment issue.
Uses of definitions in non-null environments are usually such that it
is easy to recompile the whole shebang.  You can't do it with COMPILE,
but in Hemlock, all I have to do is "Compile Defun".
     - What if I wanted to add a variable to the lexical environment?  What
       forms to I type to splice something in?
Not defined in Common Lisp.  I have been living without it.
     - What if I want to redefine add-and-increment to be interpreted?  Are you
       forcing all implementations to have the same compiler and interpreter
If you can't redefine it without its environment, you can't redefine
it to be interpreted without EVAL'ing it all, thus there is no problem.
     - 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
Well, you can expect whatever you want... :-)
Spice Lisp doesn't let you use COMPILE on functions defined in a non-null
environment.  Why not?  Because it's hard to implement and not worth
the effort.  Of course, Common Lisp COMPILE could just do nothing in
this case.

    I don't have answers for any of those.  My personal feeling is
    that DEFUN that requires a non-null lexical environment, such as
    created by LET, is a timebomb ticking quickly.
I think many of the cited problems are contingent in the assumption
that COMPILE lets you do everything you want to do.  You are bothered
mostly by programming environment issues which Common Lisp mostly
doesn't address.