[plt-scheme] Ambiguous grammar at bottom of 6.3 of PLT MzLIB

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Apr 30 18:29:17 EDT 2007

At Mon, 30 Apr 2007 22:22:15 +0000 (UTC), Kyle Smith wrote:
> Hello all,
> 
> I found this at the bottom of 6.3 of the PLT MzLib: Libraries Manual:
> 
>  (define/public (header . formals) expr)
> =expands=>
>  (begin
>   (public name)
>   (define (header . formals) expr))
> 
> As you can see the expansion involves the creation of a name 
> out of thin air; so this has to be a documentation bug.   I've 
> tried to infer what it might be that the author actually meant 
> to write, but I get syntax errors no matter how I've arranged 
> things any time I add that decimal point in between what is 
> being called the header and the formals.  In short, I just don't 
> get it.  Has anyone used this syntax successfully?

I meant to write `name' instead of `header'.

Probably I should further re-write this to avoid the `.'. Normally,
`formals' is a parenthesized sequence of identifiers:

 (define/public (addup . (n1 n2 n3)) (+ n1 n2 n3))

which we would always write instead as

 (define/public (addup n1 n2 n3) (+ n1 n2 n3))

The only time we'd actually write `.' is if the method should take any
number of arguments:

 (define/public (addup . ns) (apply + ns))


Matthew



Posted on the users mailing list.