Next: stdlib syntax-case intro expand, Previous: stdlib syntax-case intro ex, Up: stdlib syntax-case intro [Index]
A wrapped syntax object can be implemented as a record instance containing an S–expression and lexical context informations; wrapped syntax objects are a disjoint type of values. An unwrapped object is an S-expression, a structure of pairs and/or vectors, holding datums and syntax objects.
Fully unwrapping a syntax object means to convert it into an S–expression in which all the symbols are turned into identifiers and the identifiers are the only syntax objects. The identifier is the simplest syntax object with lexical informations in it; the symbol is the only element of an input form which needs lexical informations; so the wrapped syntax object:
#<syntax (1 ciao)>
is unwrapped to:
(1 #<syntax ciao>)
A syntax object can be partially unwrapped, for example:
#<syntax (the-macro 1 hello #(ciao 2) 3 salut)>
can be unwrapped to:
(#<syntax the-macro> 1 #<syntax hello> #<syntax #(ciao 2)> 3 #<syntax salut>)
which still contains the wrapped syntax object ‘#<syntax #(ciao 2)>’.
The function unwrap
defined above fully unwraps its
argument; notice that it will unwrap also quoted S–expressions, for
example:
#<syntax (a b '(1 2 #\c d))>
is unwrapped to:
(#<syntax a> #<syntax b> (#<syntax quote> (1 2 #\c #<syntax d>)))
this is not always what we want.