From: John D. Burger
Subject: Re: macro misbehaviour
Date: 
Message-ID: <1991Jun13.200317.28195@linus.mitre.org>
Bruce Krulwich (········@ils.nwu.edu) writes:

  Two recently posted macro questions suffer from the same problem:
  In each case there is some code that is only run once that "should"
  be run several times.

  The problem in each case is that computation is done at the time the
  macro is expanded that should be done at the time the macro result
  is executed.  In other words, the code for a DEFMACRO (i.e., the
  code which takes arguments and returns a list which is later
  executed) can and should only be executed once, and the list which
  it returns is then plugged into the program and executed as often as
  desired.

In fact, an implementation may cache a macro expansion for a given
environment and set of arguments.  So, if twenty-seven functions
contain the code (BLAH X (+ Y Z)), the BLAH expander might only be
called ONCE.

I think it's important to think of a macro as a function that happens
to compute some Lisp code, NOT as a function to do whatever that Lisp
code will do.

--
John Burger                                               ····@mitre.org

"You ever think about .signature files? I mean, do we really need them?"
  - alt.andy.rooney