[R6RS] Fresh syntax
dyb at cs.indiana.edu
dyb at cs.indiana.edu
Wed May 10 08:42:29 EDT 2006
> Besides, something more than FRESH-SYNTAX alone would be needed,
> since FRESH-SYNTAX wouldn't directly provide a way to apply fresh marks
> to x and y, which are already syntax objects.
Why do you need to apply fresh marks to x and y? Wouldn't
(define-syntax main
(lambda (stx)
(let ((make-swap
(lambda (x y)
(with-syntax ((x x) (y y) (t (fresh-syntax t)))
(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)))))))))
do what you want? The equivalent:
(define-syntax main
(lambda (stx)
(let ((make-swap
(lambda (x y)
(with-syntax ((x x) (y y) ((t) (generate-temporaries '(*))))
(syntax
(let ((t1 x))
(set! x y)
(set! y t1)))))))
(syntax-case stx ()
((_)
(with-syntax ((swap (make-swap (syntax s) (syntax t))))
(syntax
(let ((s 1) (t 2))
swap
(list s t)))))))))
works as intended with the reference implementation I posted.
In general, one should rarely if ever need to do anything to identifiers
that come from the input except for insert them unchanged into the output.
Kent
More information about the R6RS
mailing list