Variable transformers and transformer forms David Feuer (24 Jun 2006 20:50 UTC)
Re: Variable transformers and transformer forms Per Bothner (25 Jun 2006 03:02 UTC)
Re: Variable transformers and transformer forms David Feuer (26 Jun 2006 20:58 UTC)

Variable transformers and transformer forms David Feuer 24 Jun 2006 20:50 UTC

Jorgen Schaefer (forcer) wrote
> According to section 3.4, transformers are procedures which accept a
> single argument. Not only is this incompatible with existing systems
> (such as explicit renaming), it is also problematic for later
> extension. I think it would be more useful to use a new form here,
> such as (SYNTAX-TRANSFORMER STX (SYNTAX-CASE STX ...)) or
> (SYNTAX-LAMBDA (STX) (SYNTAX-CASE STX ...)).

I wholeheartedly agree that a new form is necessary.  In keeping with
the precedent set by R5RS, as well as the syntactic closure system of
MIT Scheme, I would propose
(define-syntax foo
   (syntax-case-transformer
      (lambda (stx) body ...)))

As a convenience form I would suggest
(syntax-transformer (stx) body ...) => (syntax-case-transformer
(lambda (stx) body ...)).  The advantage of this over Mr. Schaefer's
suggestion is that it more closely mirrors the LAMBDA form, and allows
additional arguments to be added more easily.

Furthermore, adding such a form would allow a far more natural
definition of variable transformers:  Rather than using
make-variable-transformer, one would write

(define-syntax foo (syntax-case-variable-transformer
   (lambda (stx) body ...))

with the convenience form

(variable-transformer (stx) body ...) => (syntax-case-variable-transformer
   (lambda (stx) body ...))

David Feuer