[plt-scheme] [R6RS] syntax-rules woes

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue May 13 19:45:29 EDT 2008

At Wed, 14 May 2008 00:17:01 +0100, Filipe Cabecinhas wrote:
> Hi,
> 
> I'm writing a macro that can be distilled to the following form:
> (define-syntax a
>    (syntax-rules (-)
>      [(a b ... - c - . d)
>       (list b ... c 'd)]))
> 
> When I try to use it with an empty 'd, it works:
>  > (a 1 2 3 - 42 -)
> {1 2 3 42 ()}
> 
> But, if I try to put something after the last '-, it says it's bad  
> syntax:
>  > (a 1 2 3 - 42 - 1 2 3 4)
> a: bad syntax in: (a 1 2 3 - 42 - 1 2 3 4)
> 
>  From the R6RS standard, I think it should match:
> 	• P is of the form (P1 ... Pk Pe <ellipsis> Pm+1 ... Pn . Px), where  
> <ellipsis> is the identifier ... and F is a list or improper list of n  
> elements whose first k elements match P1 through Pk, whose next m - k  
> elements each matchPe, whose next n - m elements match Pm+1 through  
> Pn, and whose nth and final cdr matches Px.
> 
> 
> Is this a bug or am I missing something?

"nth and final" means that the part matching `Px' cannot be a pair.

Matthew



Posted on the users mailing list.