License: Public Domain , Load it with Quicklisp: (ql:quickload "evaled-when")
Library type: Macro , Project complexity: Trivial/Simple

evaled-when provides a way of extracting and replicating the compile-time side-effects of forms.

Overview

Many macros have interesting compile-time side-effects that would normally be hard or impossible to replicate without integrating with their internals.

evaled-when allows you to trivially and portably extract and replicate these compile-time side-effects, which can be useful if you're trying to make a better version of defclass (as indeed I am), for instance.

Dictionary

Dictionary » evaled-when

Package evaled-when

Description

One should normally import a single symbol from this package, evaled-when.
Any other symbols from this package should normally be explicitly qualified, such as evaled-when:parse-situations. Or you could import those you use a lot.
Don't (:use)!

Macro evaled-when

(&rest situations) &body body &environment env => nil

Arguments and Values

  • situations -- A list of symbols.
  • body -- An implicit progn.
  • env -- An environment.

Description

Executes the compile-time side-effects of body at compile-time. Nothing is executed at load time or runtime.

situations must be (:compile-toplevel), else the consequences are undefined.

Bind forms to the result of (evaled-when:extract-compile-toplevel-forms body env).
If forms is nil, return nil, else return `(eval-when (:compile-toplevel) ,@forms).

Dictionary » extract-compile-toplevel-forms

Function evaled-when:extract-compile-toplevel-forms

body &optional env processing-mode => compile-toplevel-forms

Arguments and Values

  • body -- An implicit progn.
  • env -- An environment. The default is nil, the global environment.
  • processing-mode -- :not-compile-time or :compile-time-too. The default is :not-compile-time, and most users should never need to provide this argument.
  • compile-toplevel-forms -- An implicit progn.

Description

Walks body as a list of top-level forms in env according to CLHS 3.2.3.1 Processing of Top Level Forms, returning the forms that would be evaluated at compile-time (assuming the body is actually at top-level).

Dictionary » parse-situations

Function evaled-when:parse-situations

situations => compile-toplevel, load-toplevel, execute

Arguments and Values

Description

Helps parse eval-when situations lists.

compile-toplevel will be true if situations contains the symbol :compile-toplevel or compile at least once, else it will be false.

load-toplevel will be true if situations contains the symbol :load-toplevel or load at least once, else it will be false.

execute will be true if situations contains the symbol :execute or eval at least once, else it will be false.

The consequences are undefined if situations is not a list containing only the 6 aforementioned symbols corresponding to the 3 eval-when situations.