This unit has support for syntax- and module handling. This unit is used by default, unless the program is compiled with the -explicit-use option.
- (get-line-number EXPR) procedure
If EXPR is a pair with the car being a symbol, and line-number information is available for this expression, then this procedure returns the associated source file and line number as a string. If line-number information is not available, then #f is returned. Note that line-number information for expressions is only available in the compiler.
- (expand X) procedure
If X is a macro-form, expand the macro (and repeat expansion until expression is a non-macro form). Returns the resulting expression.
- (syntax-error [LOCATION] MESSAGE ARGUMENT ...) procedure
Signals an exception of the kind (exn syntax). Otherwise identical to error.
- (er-macro-transformer TRANSFORMER) procedure
Returns an explicit-renaming macro transformer procedure created from the procedural macro body TRANSFORMER, which is a procedure of three arguments.
Implementation note: this procedure currently just returns its argument unchanged and is available for writing low-level macros in a more portable fashion, without hard-coding the signature of a transformer procedure.
- (ir-macro-transformer TRANSFORMER) procedure
This procedure accepts a reverse syntax transformer, also known as an implicit renaming macro transformer. This is a transformer which works almost like er-macro-transformer, except the rename and compare procedures it receives work a little differently.
The rename procedure is now called inject and instead of renaming the identifier to be resolved in the macro's definition environment, it will explicitly inject the identifier to be resolved in the expansion environment. Any non-injected identifiers in the output expression produced by the transformer will be implicitly renamed to refer to the macro's environment instead. All identifiers in the input expression are of course implicitly injected just like with explicit renaming macros.
To compare an input identifier you can generally compare to the bare symbol and only free identifiers will match. In practice, this means that when you would call e.g. (compare (cadr expression) (rename 'x)) in an ER macro, you simply call (compare (cadr expression) 'x) in the IR macro. Likewise, an unhygienic ER macro's comparison (compare sym 'abc) should be written as (compare sym (inject 'abc)) in an IR macro.
Previous: Unit library
Next: Unit data-structures