[plt-scheme] template-ellipsis change in 299.17

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Sep 17 14:29:41 EDT 2004

I've just v299-tagged a change to macro templates. An identifier in a
template can be followed by more ellipses than the identifier has in
the pattern, and inner ellipses bind more tightly than outer ellipses.
As far as I can tell, this is consistent with Chez.

For example,

 (define-syntax s
   (syntax-rules ()
     [(_ (a ...) ((b ...) ...))
      (quote (((a b) ...) ...))]))

 (s (1 2 3) ((x y z) (a b c) (n m p)))
 = '(((1 x) (2 y) (3 z)) ((1 a) (2 b) (3 c)) ((1 n) (2 m) (3 p)))
 ;; Used to be
 ;;  '(((1 x) (1 y) (1 z)) ((2 a) (2 b) (2 c)) ((3 n) (3 m) (3 p)))
 ;; because the outer ellipses took precedence

 (define-syntax s
   (syntax-rules ()
     [(_ (a ...) ((b ...) ...))
      (quote (((a ... b) ...) ...))]))  ; used to be a "too many ellipses"
                                        ; error here, because the outer
                                        ; ellipsis took precedence for a,
                                        ; which meant that the inner ellipsis
                                        ; made no sense

 (s (1 2 3) ((x y z) (a b c) (n m p)))
 = '(((1 2 3 x) (1 2 3 y) (1 2 3 z))
     ((1 2 3 a) (1 2 3 b) (1 2 3 c))
     ((1 2 3 n) (1 2 3 m) (1 2 3 p)))

Matthew



Posted on the users mailing list.