[plt-scheme] Re: side effects in R6RS modules
On May 3, 5:46 pm, Matthew Flatt <mfl... at cs.utah.edu> wrote:
> This is a bug in our R6RS implementation. It originates with a mismatch
> between PLT Scheme's use of `#%app' to scope the application form and
> R6RS's pair-unwrapping rules for templates produced by `syntax'.
<snip>
> I'm not sure of the right solution to this problem, but I've committed
> a better approximation. When `syntax' removes wrappers, it records the
> wrapper in a hash table (weakly mapping the unwrapped value to its
> wrapper). When an unwrapped syntax object becomes the result of a macro
> expansion, the previously removed wrappers can be restored.
>
> There are R6RS programs where this strategy won't work, including
> programs that use `cons' directly instead of the `syntax' template
> form. I'll have to think more about how to improve the implementation
> further and how to document the remaining non-conformance with R6RS.
I made a checkout of the trunk and recompiled PLT. Now
everything works as you say, however my sweet-macros
library does not work anymore! It may depend from your
recent fix, or from and unrelated change, but now
it I try to compile a script which imports sweet-macros
I get
$ cat x.ss
(import (sweet-macros))
$ plt-r6rs x.ss
syntax-e: expects argument of type <syntax>; given ()
=== context ===
/usr/local/plt/collects/syntax/template.ss:118:2: loop
/usr/local/plt/collects/syntax/template.ss:118:2: loop
/usr/local/plt/collects/syntax/template.ss:118:2: loop
/usr/local/plt/collects/syntax/template.ss:118:2: loop
/usr/local/plt/collects/syntax/template.ss:118:2: loop
/usr/local/plt/collects/syntax/template.ss:118:2: loop
/usr/local/plt/collects/syntax/template.ss:118:2: loop
/usr/local/plt/collects/syntax/template.ss:118:2: loop
/usr/local/plt/collects/syntax/template.ss:118:2: loop
/usr/local/plt/collects/syntax/template.ss:118:2: loop
/usr/local/plt/collects/syntax/template.ss:118:2: loop
/usr/local/plt/collects/syntax/template.ss:118:2: loop
/usr/local/plt/collects/syntax/template.ss:118:2: loop
/usr/local/plt/collects/syntax/template.ss:118:2: loop
/usr/local/plt/collects/syntax/template.ss:118:2: loop
/usr/local/plt/collects/syntax/template.ss:118:2: loop
...
sweet-macros works with the official release of PLT,
as well as with Larceny, Ikarus, Ypsilon and Mosh
(possibly only in the SVN versions). You can find
it here: http://www.phyast.pitt.edu/~micheles/scheme/sweet-macros.zip
Apparently the sweet-macros module works quite well as a stress-test
of syntax-case, since I have found bugs in *all* R6RS
implementations where I have ported it, so you may
consider adding it to your test suite ;-)
Michele Simionato