Thursday, 19 September 2013

why notation pat ... means zero or more expressions in scheme macro pattern

why notation pat ... means zero or more expressions in scheme macro pattern

When I'm reading the macro part of The Scheme Programming Language, it
mentions that when you are trying to define a syntax extension using
define-syntax, you should use pat ... to specify zero or more expression
in the pattern. Why don't just use ... for zero or more expression, in
which case pat ... means one or more expressions?
Also, when the author gives definition of and as follows:
(define-syntax and
(syntax-rules ()
[(_) #t]
[(_ e) e]
[(_ e1 e2 e3 ...)
(if e1 (and e2 e3 ...) #f)]))
Why don't just write it like this:
(define-syntax and
(syntax-rules ()
[(_) #t]
[(_ e) e]
[(_ e1 e2 ...)
(if e1 (and e2 ...) #f)]))
I have tested this definition with some cases, and I didn't find any
problem with it.

No comments:

Post a Comment