[R6RS] Fresh syntax

dyb at cs.indiana.edu dyb at cs.indiana.edu
Wed May 10 12:00:49 EDT 2006

> Yes, that works (and I confess I didn't think of it, because I was too 
> busy reasoning about mark cancellation...)

I might have the same problem with syntax-local-introduce and
make-syntax-introducer and company, but fresh-syntax is straightforward to

> However, what I was aiming for (and what I vaguely had in mind when I 
> originally suggested FRESH-SYNTAX) was a mechanism which would allow one 
> to write syntax-processing procedures without needing to explicitly 
> generate all introduced identifiers.

I could also have written:

 (define-syntax main
   (lambda (stx)
     (let ((make-swap
            (lambda (x y)
              (with-syntax ((x x) (y y))
                  (let ((t x))
                    (set! x y)
                    (set! y t)))))))
       (syntax-case stx ()
          (with-syntax ((swap (make-swap (syntax s) (syntax t))))
              (let ((s 1) (t 2))
                (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.


More information about the R6RS mailing list