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.
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 returns a transformer, which is a procedure used by the expander to transform a syntactic extension into another syntactic extension. See also here.
So no, it's not a special form (this has disappeared from your question in the meantime), and yes, it evaluates to a value, since Scheme has first-class procedures and therefore procedures are values.
This is Scheme standard behaviour and not an implementation detail of Chicken or Chibi.