Skip to content

Syntax

The syntax library (import (syntax)) provides syntax and functions for defining Scheme keywords, more commonly known as macros. In Scheme, macros are hygienic, although there are ways to break hygiene with procedural macros.

define-syntax syntax

(define-syntax keyword expression)

The define-syntax form binds a keyword to the result of the evaluated expression which must be a transformer. A transformer is a procedure that takes one argument, a syntax object, and returns another syntax object.

Whenever the keyword is encountered, the expander will pass the syntax into the transformer and replace it with the output.

syntax syntax

(syntax expr)
#'expr

let-syntax and letrec-syntax syntax

let-syntax

(let-syntax ((keyword expr) ...) body)

letrec-syntax

(letrec-syntax ((keyword expr) ...) body)

syntax-rules syntax

Hygeinic syntax transformers

syntax-case syntax

Low-level syntax transformers

free-identifier=? procedure

(free-identifier=? identifier1 identifier2)