In Chibi and CHICKEN, the following syntax-rules
expression evaluates to a procedure:
(syntax-rules () ((_) #f))
Is this just an artifact of how these particular implementations are written? The Scheme language specs do not seem to call out syntax-rules
as being able to evaluate to a value.
Update
It seems this may depend upon the version of Scheme?
Semantics: An instance of syntax-rules evaluates, at macro-expansion time, to a new macro transformer by specifying a sequence of hygienic rewrite rules. A use of a macro whose keyword is associated with a transformer specified by syntax-rules is matched against the patterns contained in the s, beginning with the leftmost . When a match is found, the macro use is transcribed hygienically according to the template. It is a syntax violation when no match is found.
From the R5RS Spec and the R7RS Spec:
Semantics: An instance of syntax-rules produces a new macro transformer by specifying a sequence of hygienic rewrite rules. A use of a macro whose keyword is associated with a transformer specified by syntax-rules is matched against the patterns contained in the syntax rules, beginning with the leftmost syntax rule. When a match is found, the macro use is transcribed hygienically according to the template.
syntax-rules
evaluates to a value, specifically a procedure. – uselpasyntax-rules
that are not within adefine-syntax
.((syntax-rules () ((_) #f)) #'(x))
actually produces a value in #!racket :) – Sylwester