Binding syntactic keywords

Define-syntax, let-syntax, and letrec-syntax are analogous to define, let, and letrec, but they bind syntactic keywords to macro transformers instead of binding variables to locations that contain values. Furthermore, there is no define-syntax analogue of the internal definitions described in section [*].


\begin{rationale}
As discussed below, the syntax and scope rules for definitions...
...}, with scope
rules analogous to those for internal definitions.
\end{rationale}

These new expression types and the pattern language described in section [*] are added to Scheme by augmenting the BNF in section [*] with the following new productions. Note that the identifier ... used in some of these productions is not a metasymbol.


\begin{grammar}%
\meta{expression} \: \meta{macro use}
\> \Vert \meta{macro bloc...
...nsformer spec})
\> \Vert (begin \arbno{\meta{syntax definition}})%
\end{grammar}

Although macros may expand into definitions in any context that permits definitions, it is an error for a definition to shadow a syntactic keyword whose meaning is needed to determine whether some definition in the group of top-level or internal definitions that contains the shadowing definition is in fact a definition, or is needed to determine the boundary between the group and the expressions that follow the group. For example, the following are errors:


\begin{scheme}
(define define 3)
\par
(begin (define begin list))
\par
(let-synt...
...t ((x 3))
(foo (plus x y) (+ x y))
(define foo x)
(plus foo x)))
\end{scheme}


\begin{entry}{%
\proto{let-syntax}{ \hyper{bindings} \hyper{body}}{\exprtype}}
\...
...s () ((m) x))))
(let ((x 'inner))
(m)))) \ev outer\end{scheme}\par
\end{entry}


\begin{entry}{%
\proto{letrec-syntax}{ \hyper{bindings} \hyper{body}}{\exprtype}...
...
(if even?))
(or x
(let temp)
(if y)
y))) \ev 7\end{scheme}\par
\end{entry}


\begin{entry}{%
\proto{define-syntax}{ \hyper{keyword} \hyper{transformer spec}}...
...1))
(let* ((name2 val2) ...)
body1 body2 ...)))))
\end{scheme}\par
\end{entry}