Pascal Bourguignon <spam@thalassa.informatimago.com> wrote:
+---------------
| There is no fundamental difference between a function and a macro.
| The only difference, is that functions are called at so called
| "run-time" while macros are called at so called "compilation-time".
|
| Now, think about it, when you're using actually a lisp interpreter,
| when is "run-time", and when is "compilation-time"? (You can check
| CLHS to see how Common-Lisp defines these "times").
+---------------
Minor quibble: A macro-function gets called at "macro expansion time",
which can be either during compilation (see CLHS "3.2.2.2 Minimal
Compilation") or evaluation (CLHS "3.1.2.1.2.2 Macro Forms").
Whether the top-level interactive REPL provides at least "minimal
compilation" or not is an implementation decision. SBCL always does
full compilation (IIUC), whereas CMUCL does only minimal compilation of
interpreted forms, and at that not until the first time the form is
evaluated (by which I'm specifically referring to the body forms of a
function typed to the REPL), for example:
cmu> (defmacro say-expand (tag)
(format t "I'm expanding here: ~s~%" tag)
'nil)
SAY-EXPAND
cmu> (defun foo ()
(say-expand in-foo)
37)
FOO
cmu> (foo)
I'm expanding here: IN-FOO
37
cmu> (foo)
37
cmu>
-Rob
p.s. Other things besides calling a function can cause its body to
be minimally-compiled in CMUCL, e.g., if right after the definition
of FOO above you called DESCRIBE on it:
cmu> (describe 'foo)
FOO is an internal symbol in the COMMON-LISP-USER package.
Function: #<Interpreted Function FOO {488FD8B1}>
Function arguments:
There are no arguments.I'm expanding here: IN-FOO [ <== LOOK! ]
Its defined argument types are:
NIL
Its result type is:
*
Its definition is:
(LAMBDA () (BLOCK FOO # 37))
cmu> (foo)
37
cmu>
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607