1.8 Library Syntax Classes and Literal Sets
1.8.1 Syntax Classes
syntax
syntax
syntax
syntax
syntax
syntax
syntax
syntax
syntax
syntax
syntax
syntax
syntax
procedure
(static predicate description) → (attributes value)
predicate : (-> any/c any/c) description : (or/c string? #f)
When used outside of the dynamic extent of a macro transformer (see syntax-transforming?), matching fails.
The attribute value contains the value the name is bound to.
procedure
(expr/c contract-expr [ #:positive pos-blame #:negative neg-blame #:name expr-name #:macro macro-name #:context ctx]) → (attributes c) contract-expr : syntax?
pos-blame : (or/c syntax? string? module-path-index? 'from-macro 'use-site 'unknown) = 'use-site
neg-blame : (or/c syntax? string? module-path-index? 'from-macro 'use-site 'unknown) = 'from-macro expr-name : (or/c identifier? string? symbol?) = #f macro-name : (or/c identifier? string? symbol?) = #f ctx : (or/c syntax? #f) = determined automatically
The contract’s positive blame represents the obligations of the
expression being wrapped. The negative blame represents the
obligations of the macro imposing the contract—
If the argument is a string, it is used directly as the blame label.
If the argument is syntax, its source location is used to produce the blame label.
If the argument is a module path index, its resolved module path is used.
If the argument is 'from-macro, the macro is inferred from either the macro-name argument (if macro-name is an identifier) or the context argument, and the module where it is defined is used as the blame location. If neither an identifier macro-name nor a context argument is given, the location is "unknown".
If the argument is 'use-site, the module being expanded is used.
If the argument is 'unknown, the blame label is "unknown".
The macro-name argument is used to determine the macro’s binding, if it is an identifier. If expr-name is given, macro-name is also included in the contract error message. If macro-name is omitted or #f, but context is a syntax object, then macro-name is determined from context.
If expr-name is not #f, it is used in the contract’s error message to describe the expression the contract is applied to.
The context argument is used, when necessary, to infer the macro name for the negative blame party and the contract error message. The context should be either an identifier or a syntax pair with an identifier in operator position; in either case, that identifier is taken as the macro ultimately requesting the contract wrapping.
See Contracts on Macro Sub-expressions for an example.
Important: Make sure when using expr/c to use the c attribute. The expr/c syntax class does not change how pattern variables are bound; it only computes an attribute that represents the checked expression.
1.8.2 Literal Sets
syntax
Note that the literal-set uses the names #%plain-lambda and #%plain-app, not lambda and #%app.