[plt-scheme] Re: [Larceny-users] side effects in R6RS modules

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue May 5 14:29:41 EDT 2009

Then I understood: That's the "how many times a module is compiled"

A difference between `mzscheme' and `plt-r6rs' in v4.1.5 is that they
treat the module differently for top-level compilation. The `mzscheme'
executable visits everything in case there are compilations of
top-level forms, while `plt-r6rs' doesn't (because there's no REPL).
And DrScheme compiles each module multiple times.

We've made a semantic change in v4.1.5.5 compared to v4.1.5, where a
visit at phase N is delayed until an operation or form that starts
compilation at phase N (at which point everything prepared at phase N
is visited). As it happens, that change makes `mzscheme' and `plt-r6rs'
compile and initiate compilation in the same way, so they both print
"T0" 5 times --- unless you add the `-i' flag to `mzscheme', which
starts a REPL and therefore prints an extra "T0" to initialize
top-level compilation. But I wouldn't be surprised if the tools later
diverge in how many times they compile modules or initialize
compilation, and DrScheme still compiles modules a different number of

Again, it's the behavior during a single compilation of a single module
that seems matter in practice (though we've found two points that so
far work: pre- and post-v4.1.5.5), and not the number of times a module
is compiled. That's why, all else being equal, I'm inclined to specify
invocation within a single compilation as part of the language
semantics, while I'm happy to put the number of compilations outside
the language semantics. (Then again, in the context of a language
standard, all else isn't equal.)

At Tue, 5 May 2009 20:43:23 +0300, Abdulaziz Ghuloum wrote:
> On May 5, 2009, at 8:33 PM, Matthew Flatt wrote:
> > At Tue, 5 May 2009 20:27:47 +0300, Abdulaziz Ghuloum wrote:
> >> I'm talking about the same program written in the R6RS language
> >> behaving differently when run through mzscheme, plt-r6rs, and
> >> DrScheme.
> >
> > To be clear about what you mean, can you provide an example?
> If you have the following libraries:
> (library (T0) (export) (import (rnrs)) (display "T0\n"))
> (library (T1) (export) (import (for (T0) run expand)))
> (library (T2) (export) (import (for (T1) run expand)))
> (library (T3) (export) (import (for (T2) run expand)))
> And this script:
> #!r6rs
> (import (T3))
> Running the script (without precompilation) results in printing T0:
>   0 times for Ikarus
>   1 time for Larceny
>   10 times for plt-r6rs
>   13 times for mzscheme
>   22 times for DrScheme
> last time I checked (I can't try it right now, I just copied it from
> my email archives).
> Aziz,,,

Posted on the users mailing list.