Subject: Re: macro/call order [particularly in SBCL]
From: rpw3@rpw3.org (Rob Warnock)
Date: Fri, 27 Jul 2007 01:39:14 -0500
Newsgroups: comp.lang.lisp
Message-ID: <bt2dnQA0U_yPDjTbnZ2dnUVZ_rKtnZ2d@speakeasy.net>
Pascal Costanza  <pc@p-cos.net> wrote:
+---------------
| ANSI Common Lisp doesn't pose such requirements on interpreted code. An 
| implementation is allowed to expand macros lazily on each invocation, 
| and it is even allowed to reexpand them over and over again. This is 
| actually quite useful during development, because you can immediately 
| see changes in macro definitions without recompilation.
+---------------

Actually, unless an "interpreter" *does* some sort of preprocessing
to expand macros [whether or not that's 100% equivalent to ANSI CL's
"minimal compilation"] once & only once, then it is *required* to
reexpand them over and over again... since "displacing" expansion
[a.k.a. self-modifying code a.k.a. overwriting the macro call with
its expansion] is expressly forbidden, see:

    http://www.alu.org/HyperSpec/Body/sec_3-1-2-1-2-2.html
    3.1.2.1.2.2 Macro Forms

    http://www.alu.org/HyperSpec/Issues/iss301-writeup.html
    Issue SELF-MODIFYING-CODE Writeup

Many implementations (CMUCL, CLISP, most others) get around that for
performance reasons by actually doing at least Minimal Compilation
of even "interpreted" code [REPL & LOADed source], so even there
changing the function behind a macro will require re-evaluating any
defining forms [DEFUN, DEFVAR, etc.] whose values contained a call
of that macro.

+---------------
| My guess is that you haven't noticed a difference between CLISP and 
| SBCL, but rather a difference between an interpreter and a compiler.
+---------------

No, the CLISP interpreter preprocesses at least the macros, too.


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607