Re: Question about compilation/evaluation environments

From: Peter Seibel (peter_at_javamonkey.com)
Date: 10/01/04


Date: Fri, 01 Oct 2004 18:12:30 GMT

Pascal Bourguignon <spam@mouse-potato.com> writes:

> "Tim Bradshaw" <tfb+google@tfeb.org> writes:
>
>> Pascal Bourguignon wrote:
>> >
>> > Why should it store it in the compilation environment?
>>
>> Because the language spec says it should. It ought to work to say
>
> I expressed myself incorrectly.
>
> "DEFUN is to required to perform any compile-time side effects."

I assume that first "to" is supposed to be a "not". Anyway, here's the
quote cut-n-pasted from the Hyperspec:

  "defun is not required to perform any compile-time side effects. In
  particular, defun does not make the function definition available at
  compile time." (emphasis mine)

On the other hand:

  "If a defmacro form appears as a top level form, the compiler must
  store the macro definition at compile time, so that occurrences of
  the macro later on in the file can be expanded correctly. Users must
  ensure that the body of the macro can be evaluated at compile time
  if it is referenced within the file being compiled."

> If a macro use a function, the programmer has to ensure that this
> function is in the compilation environment with EVAL-WHEN.

Yes. But none of my macros use functions; only other macros.

> The macro QUUX uses the macro BAZ which uses the function FOO,
                                                   ^^^^^^^^

Look again, FOO is a macro. The only function was BAR which is never
used--I just threw it in so I could talk about compiling a function.

-Peter

-- 
Peter Seibel                                      peter@javamonkey.com
         Lisp is the red pill. -- John Fraser, comp.lang.lisp


Relevant Pages

  • Re: modifying array access syntax
    ... I published recent speculation on the ARRAY ... > are in fact remnants of the property lists of these Lisp-N ... these that were meaningful at compile time (FEXPR, FSUBR, and MACRO ...
    (comp.lang.lisp)
  • Re: macro functionality in embedded languages.
    ... One advantage of the macro style is efficiency - the call expands at ... compile time and can be compiled with full optimization. ...
    (comp.lang.lisp)
  • Re: Please review macro
    ... >>compile time about into what code the particular macro invocation should ... Mind you, at the repl I guess you get both ... dramatic results unless you compile the macro first. ...
    (comp.lang.lisp)
  • Re: DISFAVORED Was: name for 3 PICK finally?
    ... complexity is reduced by reducing the phases of execution to keep ... outside happens when the word containing the macro executes. ... LITERAL COMPILE, .... ... ``GET LITERAL @ LITERAL `EXECUTE COMPILE,'' ...
    (comp.lang.forth)
  • Re: Open stack and colon definitions as a features (was: Of course it IS!!!)
    ... execute at compile time like immediate words did thirty years ... So now we also know what color a macro has: ... In Chuck's colorforth green is more like "]" and yellow is ... They do something more like change the system's STATE to execute ...
    (comp.lang.forth)