Subject: Re: elisp macros problem
From: (Rob Warnock)
Date: Wed, 28 Jul 2004 00:03:57 -0500
Message-ID: <>
Pascal Bourguignon  <> 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 " Minimal
Compilation") or evaluation (CLHS " 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)

    cmu> (defun foo ()
	   (say-expand in-foo)

    cmu> (foo)
    I'm expanding here: IN-FOO
    cmu> (foo)



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:
    Its result type is:
    Its definition is:
      (LAMBDA () (BLOCK FOO # 37))
    cmu> (foo)


Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607