[R6RS] Fresh syntax

Anton van Straaten anton at appsolutions.com
Wed May 10 12:39:34 EDT 2006


> I might have the same problem with syntax-local-introduce and
> make-syntax-introducer and company, but fresh-syntax is straightforward to
> me. 
...
> I could also have written:
> 
>  (define-syntax main
>    (lambda (stx)
>      (let ((make-swap
>             (lambda (x y)
>               (with-syntax ((x x) (y y))
>                 (fresh-syntax
>                   (let ((t x))
>                     (set! x y)
>                     (set! y t)))))))
>        (syntax-case stx ()
>          ((_)
>           (with-syntax ((swap (make-swap (syntax s) (syntax t))))
>             (syntax
>               (let ((s 1) (t 2))
>                 swap
>                 (list s t)))))))))
> 
> so that all introduced identifiers are fresh.  In this example, the effect
> is the same, but in general, none of the identifiers, including t,
> introduced by the fresh-syntax form would conflict with bindings or
> references introduced by the body of the transformer or its other helpers.

I wasn't able to write a correct equivalent of the above example using 
make-syntax-introducer.  If fresh-syntax works as above, then I think 
I'm satisfied (for now!), except that FRESH-SYNTAX isn't yet part of the 
proposal.

Anton



More information about the R6RS mailing list