Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!spool.mu.edu!agate!linus!linus!thelonius!john From: john@thelonius.mitre.org (John D. Burger) Newsgroups: comp.lang.lisp Subject: Re: macro misbehaviour Message-ID: <1991Jun13.200317.28195@linus.mitre.org> Date: 13 Jun 91 20:03:17 GMT Sender: news@linus.mitre.org (News Service) Organization: The MITRE Corporation, Bedford, MA 01730 Lines: 28 Nntp-Posting-Host: thelonius.mitre.org Bruce Krulwich (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 john@mitre.org "You ever think about .signature files? I mean, do we really need them?" - alt.andy.rooney