chickadee » chicken » syntax » ir-macro-transformer

ir-macro-transformer TRANSFORMERprocedure

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. See the section above for a more complete explanation.

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.