[r6rs-discuss] Comments on syntax-rules

From: David Van Horn <dvanhorn>
Date: Wed Nov 1 16:53:41 2006

David Van Horn wrote:
> ...
> This would make some of the language surrounding define-, let-, and
> letrec-syntax clearer. For example, it would seem that syntax-rules
> transformers are disallowed in (r6rs syntax-case) because "A

Uh... my email got truncated. Here it is again.

A few notes and questions on syntax-rules:

1) With the addition of <fenders> into the language of syntax-rules, the
following no longer seems true:

- a facility (syntax-case; see chapter 17) for creating
transformers via a pattern language that permits the
use of arbitrary Scheme code, and a derived facility
(syntax-rules; see section 9.21) for creating transformers
via the pattern language only.

Since <fender> may make use of arbitrary Scheme code.

2) Why not make syntax-rules evaluate to a transformer procedure? This
is common among R5RS implementations that support syntax-case, where
they often use the definition of syntax-rules from TSPL:

(define-syntax syntax-rules
   (lambda (x)
     (syntax-case x ()
       ((_ (i ...) ((keyword . pattern) template) ...)
        (syntax (lambda (x)
                  (syntax-case x (i ...)
                    ((dummy . pattern) (syntax template))
                    ...)))))))

This would make some of the language surrounding define-, let-, and
letrec-syntax clearer. For example, it would seem that syntax-rules
transformers are disallowed in (r6rs syntax-case) because "A
<transformer spec> must be an expression that evaluates to a procedure,"
but earlier (9.3) it is implied that a syntax-rules form does not
evaluate to a procedure by the distinction that a <transformer spec>
"must either evaluate be a syntax-rules form, or evaluate, at
macro-expansion time, to a transformer." (This distinction is repeated
in 9.20).

This would also allow for variable transformers to be implemented with
syntax-rules. This is currently disallowed since
make-variable-transformer takes a procedure argument. If this change is
made, it would seem sensible to move make-variable-transformer into the
base library.

3) Why not cut the specification of syntax-rules, which is later
subsumed and partly duplicated by the specification of syntax-case, and
simply replace the current specification with its definition in terms of
syntax-case? (This would incidentally make syntax-rules evaluate to a
procedure at macro-expansion time.)

4) Why not allow <srpattern> to also be an underscore so that examples
such as p.car could be written with just syntax-rules and without the
need of (r6rs syntax-case)?

David
Received on Wed Nov 01 2006 - 16:53:33 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:00 UTC