[r6rs-discuss] Comment 92: Phase semantics
A couple of further comments:
> The two implementation approaches differ on three related points:
>
> 1. Whether instances of a library at different phases are the same
> or different.
>
> This is arguably the driving distinction. PLT Scheme and Van
> Tonder's implementation instantiate a library separately for each
> phase, and even for each individual compilation of a library. The
> motivation for separating instances is to maximize the similarly
> between compiling and executing libraries all in the same run-time
> system instance, versus compiling libraries in separate instances
> of the run-time system.
I don't believe this particular motivation forces one to
separate the instantiations that are present at compile-time.
The property in question can be satisfied even in a system that shares
library instances between all levels present at compile-time.
To satisfy the stated property, it is only necessary that every expansion
of a library or program, and every execution of a program,
happen in a fresh instantiation environment.
In other words, it is possible to make a system (as I have) that is
deterministic in the sense described above but where all expand-time
meta-levels do share an instance, as long as runtime and
expand-time instances are not the same.
> "Phase": an execution time, such as run-time or expand-time. The
> notion of phase is inherently relative to some library; the "run time"
> of one library may be the "expand time" of some other library that
> imports the former for use by procedural macros.
>
> "Phase shift": the execution time of a variable or keyword reference
> relative to a library that is being expanded and parsed. For example,
> when an identifier appears in an unquoted position on the right-hand
> side of a `define-syntax' form, it is either parsed as a variable with
> a phase shift of 1, because it access a variable at expand time
> (relative to the enclosing library), or it is parsed as a keyword whose
> use with a phase shift of 1, because the use is expanded at expand
> time.
>
> "Levels": potential phase shifts for an identifier relative to the
> lexically enclosing library. An unparsed identifier has levels in its
> source context; a parsed variable or keyword has a phase shift in its
> use context.
I think it is confusing (at least to me) to identify "levels" with
"phases/execution times". One can come up with examples where they
are apparently not the same thing.
Here is an example where meta-levels are not execution times:
(library (baz)
(export x)
(import (r6rs))
(define x 42))
(library (foo)
(export template)
(import (for (baz) expand)
(for (r6rs) run (meta -1)))
(define template
(syntax (let-syntax ((m (lambda (_)
(let-syntax ((n (lambda (_) x))) ; <-- (1)
(n)))))
(m))))
(let-syntax ((n (lambda (_) x))) ; <-- (2)
(n)))
Both references to x occur at level 1 and are given a meaning by the
(for (baz) expand) in the import. However, while reference (2) is indeed
evaluated during expansion of (foo), reference (1) is not, even though it is
imported "for expand". It can be evaluated at some later time, in some
different
image or machine, when imported into some client of (foo); for example,
(library (bar)
(export)
(import (r6rs)
(for (foo) expand))
(let-syntax ((n (lambda (_) template)))
(display (n)))) ;==> 42
I think this shows that "for expand" is a misnomer as far as reference (1)
in (foo) is concerned. It also calls into question the identification of
levels with phases.
Cheers
Andre
Received on Thu Jan 04 2007 - 07:31:23 UTC
This archive was generated by hypermail 2.3.0
: Wed Oct 23 2024 - 09:15:01 UTC