12.5 Syntax Parameters (original) (raw)

12.5 Syntax Parameters🔗

Binds id as syntax to a syntax parameter. The expr is an expression in thetransformer environment that serves as the default value for the syntax parameter. The value is typically obtained by a transformer using syntax-parameter-value.

The id can be used with syntax-parameterizeor syntax-parameter-value (in a transformer). Ifexpr produces a procedure of one argument or amake-set!-transformer result, then id can be used as a macro. If expr produces amake-rename-transformer result, then id can be used as a macro that expands to a use of the target identifier, butsyntax-local-value of id does not produce the target’s value.

Examples:

(syntax-parameterize ([id expr] ...) body-expr ...+)

Each id must be bound to a syntax parameter usingdefine-syntax-parameter. Each expr is an expression in the transformer environment. During the expansion of thebody-exprs, the value of each expr is bound to the corresponding id.

If an expr produces a procedure of one argument or amake-set!-transformer result, then its idcan be used as a macro during the expansion of thebody-exprs. If expr produces amake-rename-transformer result, then id can be used as a macro that expands to a use of the target identifier, butsyntax-local-value of id does not produce the target’s value.

Examples:

Examples:

Added in version 6.3.0.14 of package base.

12.5.1 Syntax Parameter Inspection🔗

This procedure is intended for use in a transformer environment, where id-stx is an identifier bound in the normal environment to a syntax parameter. The result is the current value of the syntax parameter, as adjusted bysyntax-parameterize form.

This binding is provided for-syntax byracket/stxparam, since it is normally used in a transformer. It is provided normally byracket/stxparam-exptime.

This procedure is intended for use in a transformer, whereid-stx is an identifier bound to a syntax parameter. The result is a transformer that behaves as id-stx, but that cannot be used with syntax-parameterize orsyntax-parameter-value.

Using make-parameter-rename-transformer is analogous to defining a procedure that calls a parameter. Such a procedure can be exported to others to allow access to the parameter value, but not to change the parameter value. Similarly,make-parameter-rename-transformer allows a syntax parameterto be used as a macro, but not changed.

The result of make-parameter-rename-transformer is not treated specially by syntax-local-value, unlike the result of make-rename-transformer.

This binding is provided for-syntax byracket/stxparam, since it is normally used in a transformer. It is provided normally byracket/stxparam-exptime.