[R6RS] Fresh syntax
Anton van Straaten
anton at appsolutions.com
Wed May 10 11:43:39 EDT 2006
(Sorry about my previous message being triplicated. My service
provider's mail server was acting as a black hole for a while this morning.)
dyb at cs.indiana.edu wrote:
>> 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
>
> (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?
Yes, that works (and I confess I didn't think of it, because I was too
busy reasoning about mark cancellation...)
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. More generally, it would be ideal
if code from a transformer could be extracted to an external procedure
without the semantics changing, and requiring changes to recover the
original semantics.
My sense is that SRFI 72's QUASISYNTAX mechanism at least simulates this
ability better (and may even actually achieve it, I'm not sure).
WITH-FRESH-SYNTAX was an attempt to provide similar behavior.
By way of support for the need for this, Dave Herman at Northeastern
(down the corridor from Will) wrote a short post about this issue:
http://calculist.blogspot.com/2005/04/hygienic-macros-are-generative.html
I believe that the macro which prompted this post is described here:
http://calculist.blogspot.com/2005/04/ask-and-ye-shall-receive-my-bugs.html
Dave ends the former post by saying "I wonder what kind of reasoning
tools can help mitigate the problems hygiene causes with understanding
macros." That's what I'm after here.
Anton
More information about the R6RS
mailing list