[plt-scheme] combining ... and . in syntax-case patterns

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Jan 22 20:36:00 EST 2008

If I'm reading R6RS as intended, I've changed MzScheme to match it:

 * The intended old MzScheme constraint was that the match to `more'
   could not be a pair or null, but that constraint was neither
   correctly documented nor correctly implemented.

 * The R6RS constraint is that it can't be a pair, but a null is ok. I
   can see how that slight generalization is useful, and the old
   behavior (useful for error checking) is relatively easy to get back
   with a guard.

The change broke two macros, `lambda/kw' and `match', which I fixed
with a guard. Probably there will be one more broken macro out there
somewhere.

It's still not what Sam wants, though, which is a kind of greedy
pattern match.

Thanks,
Matthew

At Sat, 19 Jan 2008 23:01:44 -0500, Abdulaziz Ghuloum wrote:
> 
> On Jan 19, 2008, at 2:56 PM, Robby Findler wrote:
> 
> > But it seems like syntax-case should signal a syntax error for
> > patterns like that (altho perhaps there is some interesting reason why
> > that's tricky?)
> 
> But that pattern does work as expected under both chez and ikarus  
> (see below), works under mzscheme for some inputs (first example  
> below), and is required to work under R6RS.  So, maybe, it's just a  
> small bug somewhere.
> 
> Aziz,,,
> 
> Welcome to MzScheme v371 [3m], Copyright (c) 2004-2007 PLT Scheme Inc.
>  > (syntax-object->datum
>      (syntax-case #'foo ()
>        [([v t] ... . more)
>         #'(v ...)]
>        [_ (error)]))
> ()
> 
> 
> Petite Chez Scheme Version 7.4
> Copyright (c) 1985-2007 Cadence Research Systems
> 
>  > (syntax-case #'([x0 y0] [x1 y1]) ()
>        [([v t] ... . more)
>         #'(v ...)]
>        [_ (error)])
> (#<syntax x0> #<syntax x1>)
> 
> 
> Ikarus Scheme version 0.0.2patched+ (revision 1351, build 2008-01-19)
> Copyright (c) 2006-2007 Abdulaziz Ghuloum
> 
>  > (syntax-case #'([x0 y0] [x1 y1]) ()
>      [([v t] ... . more)
>       #'(v ...)]
>      [_ (error)])
> (#<syntax x0> #<syntax x1>)
> 
> 
> Welcome to MzScheme v371 [3m], Copyright (c) 2004-2007 PLT Scheme Inc.
>  > (syntax-case #'([x0 y0] [x1 y1]) ()
>      [([v t] ... . more)
>       #'(v ...)]
>      [_ (error)])
> error: expects at least 1 argument, given 0
> 
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme


Posted on the users mailing list.