[R6RS] syntax-case

dyb at cs.indiana.edu dyb
Mon Apr 11 17:02:39 EDT 2005

> That's true. Would you consider adding a conventional special character
> for marking non-literal as a burden? For instance, in Bigloo, we are
> using "?". That is:
>        [(_ ((x e) ...) b1 b2 ...) <expression>]
> is written
>        [(?- ((?x ?e) . ?rest1) ?b1 ?b2 . ?rest2) <expression>]

> I agree that since in the context of macros most elements are pattern 
> variables, your syntax is nicer than the one deployed by a general pattern
> matching syntax. However, my personal feeling is that the "?" mark is
> not very intrusive nor error prone. 

I don't mind this as a convention, but I do see it as a burden if required.
I might be able to learn to live with it.

> >   * Neither pattern variables nor literal identifiers are explicitly
> >     marked in an output form; instead, pattern variables are distinguished
> >     from ordinary variables.  The syntax form inserts the values of
> >     pattern variables into the output, while treating other identifiers,
> >     including other variables, as literal syntax.  The syntax form also
> >     handles ellipses.
> Isn't in contradiction with the fact that SYNTAX-CASE allows the output
> to be constructed by arbitrary Scheme code. Is it correct to think that
> everything works fine as long as the arbitrary code is a #'expression?

The right-hand side of a syntax-case clause is an arbitrary expression.
Within the arbitrary expression can appear syntax forms, which are written
as (syntax <template>) or #'<template>.  Pattern variables and ellipses
can appear only within a <template>.

> I'm not familiar enough with your fender proposal to really understand
> all the implications. In with context is evaluated the fender? Is it in a
> context where all the pattern variables are bound to syntaxes? How would you 
> write an equivalent to:
>     [(+ (and (? integer?) ?v1) (and (? integer?) ?v2)) <expr>]
> Would you write something such as:
>     [(_ e1 e2) (and (integer? (syntax-object->datum e1) (syntax-object->datum e2))) <expr>]

If I understand your syntax, yes.  It would actually look like:

    [(_ e1 e2)
     (and (integer? (syntax-object->datum e1))
          (integer? (syntax-object->datum e2)))

which is what you probably meant.


More information about the R6RS mailing list