I think I found a clearer way of talking about this. This rule: (define-syntax-rule (test (x y ...) ...) '(((x y) ...) ...))

Has more than one possible meaning. But it can be clarified using explicit subscripts. It could mean either this (which is what I expected): (define-syntax-rule (test (x_j y_j_i ...i) ...j) '(((x_j y_j_i) ...i) ...j)) Or this (which is what Racket does): (define-syntax-rule (test (x_j y_j_i ...i) ...j) '(((x_i y_j_i) ...i) ...j)) I'm surprised that x's subscript changed between the pattern and the template. Ryan, thanks for the interesting example. Made explicit, it becomes: ((x_j x_i ...i) ...j) although figuring out how to label that was tricky and I don't know how to do it in general, or even if it can be done for all valid syntax rules. Matthias: the algorithm I was thinking of is the Macro-by-Example algorithm that Ryan pointed out, which is neither of yours. Decompose the environment at the outer ellipsis. I take back my claim that it's the most obvious algorithm, though. On Tuesday, March 27, 2018 at 6:05:12 PM UTC-4, Ryan Culpepper wrote: > > On 03/27/2018 11:46 PM, Ryan Culpepper wrote: > > On 03/27/2018 10:01 PM, Justin Pombrio wrote: > >> I'm surprised by the behavior of using a pattern variable under one > >> set of ellipses in the pattern, and under two sets of ellipses in the > >> template: > >> [...] > > BTW, it looks like Macro-By-Example[1] describes the behavior that you > expected. See the definitions in the second column of page 4. > > Ryan > > [1] "Macro-By-Example: Deriving Syntactic Transformations from their > Specifications" by Eugene Kohlbecker and Mitchell Wand. > ftp://www.cs.indiana.edu/pub/techreports/TR206.pdf > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.