[previous] [up] [next]     [index]
Next: Support Facilities Up: Macros Previous: Expansion Time Binding and

Primitive Syntax and Expanding Macros

Only the syntactic forms shown in Figure 13.1 will occur in a fully expanded expression. The dagger next to cond indicates that it will appear only with zero clauses, and only in the compilation mode where the exn:else exception is raised if no clause matches (see section 3.2).

figure89933
Figure 13.1: Syntactic forms after expanding with expand-defmacro

Like macros, primitive syntax names are bound in the global namespace, and primitive syntax values can be obtained with global-defined-value.

(syntax? v) returns #t if its argument is a primitive syntax value, #f otherwise.

(expand-defmacro s-expr) expands all macros in the S-expression s-expr and returns the new, expanded S-expression.

(expand-defmacro-once s-expr) partially expands macros in the S-expression s-expr and returns the partially-expanded S-expression.

(local-expand-defmacro s-expr [shadow-list]) expands s-expr during expansion-time (see section 13.3), and locally-defined macros are used from the context of the expression currently being expanded. (This procedure is normally used in the implementation of a macro.) If shadow-list is provided, it must be a list of symbols, which local-expand-defmacro treats as identifiers that shadow syntax bindings the current lexical environment. If local-expand-body-expression is invoked at run time, the exn:misc exception is raised.

(local-expand-body-expression s-expr [shadow-list]) expands expands s-expr only far enough to determine whether it expands to a define-values or begin expression. The result is two values: the (partially expanded) expression and either '#%define-values, '#%begin, or #f (where #f means the expression has some other form). If local-expand-defmacro is invoked at run time, the exn:misc exception is raised.



PLT