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

Definition time macros

 >I've been discussing the desirabilty of doing DEFUN-time expansion and
 >other source-level transforms with some of the H-P people since I
 >started using their system.  In my view, the only reason to have an
 >interpreter around at all is that it is much easier to debug code if it
 >is still more or less what you wrote.  Once the proverbial clever
 >compiler has come in and changed everything beyond recognition, you may
 >as well let it go ahead and finish compiling.  Just doing the expansions
 >and source-level transforms gets you the worst of both worlds: the code
 >is unreadable, but not fast.
This is a good point that I had not considered.  I agree that its
important to have interpreted code present (one of the big loses of
the ExperLisp system on the Macintosh is that its compiler only - that
makes debugging very difficult).
 >So it is a desirable goal to have interpreted code exactly match
 >compiled code, but it is also a desirable goal to have a good
 >source-language debugging environment in the interpreter.  It's a
 >trade-off.  In my experience, the differences introduced by expanding
 >macros at execution time, rather than definition time, are not
 >troublesome in practice and are not the kind of thing that a beginner is
 >going to run into.
I can only say that in quite a number of times in teaching Lisp, I
have seen the students "discover" that one can do anything one wants in
a macro and invariably screw themselves.  I think that some of it may
be legitimate because of the lack of Fexprs.  They don't seem to
realize that its easy to write a macro to quote the arguments that
then calls the auxillary function.  As students typically do, they
look for the short cut and combine it all into one macro.  sigh...
 > ...  (Actually, that statement assumes that the compiler
 >does macro-expansion and then code generation in the same recursive
 >descent.  If all of the source-level transforms are done in a pre-pass,
 >as H-P likes to do, you can get some more glaring discrepancies, and
 >defun-time expansion looks a bit more important.)
 >-- Scott