Email list hosting service & mailing list manager

Library semantics correction Andre van Tonder (03 Dec 2005 17:19 UTC)
Re: Library semantics - higher level imports Andre van Tonder (04 Dec 2005 14:39 UTC)
Re: Library semantics - higher level imports Andre van Tonder (04 Dec 2005 14:51 UTC)

Re: Library semantics - higher level imports Andre van Tonder 04 Dec 2005 14:39 UTC

It would be straightforward to extend this to higher level imports.  First, the
import syntax might be modified to something similar to:

   (for "library" (phase 0)
                  (phase 1)
                  (phase 3))  ; imports into phases 0, 1 and 3

where (phase 0) = RUN
       (phase 1) = SYNTAX

Example:

   (library "m" "r6rs"
    (export x)
    (define x 1))

   (library "n" "r6rs"
     (import (for "m" (phase 2)))
     (let-syntax ((a (lambda (exp)
                       (let-syntax ((b (lambda (exp) x))) ; use of x
                          (b)))))
       (a))

The change in the semantics would then be:

To visit a library at phase N:

     * Visit at phase N any library that is imported by this library
       for ... (phase 0), and that is not yet visited at phase N.
  [MODIFIED]
     * For each k >= 1, invoke at phase N+k any library that is imported
       by this library for .... (phase k), and that is not yet invoked at
       phase N+k.
  [ADDED]
     * For each k >= 1, visit at phase N+1 any library that is imported by
       this library for .... (phase k), and that is not yet visited at phase
       N+k.
     * Evaluate all syntax definitions within the library.
       (Top-level expressions are not evaluated, and the right-hand sides
       of variable definitions are not evaluated.)

Sometimes it is useful to import a library for all phases.  For example, this
may be what is implicitly done for the r6rs language, so one could also have
an option:

   (for "library" all) == (for "library" (phase 0) (phase 1) (phase 2) .....)

Regards
Andre