[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Library semantics - higher level imports

This page is part of the web mail archives of SRFI 83 from before July 7th, 2015. The new archives for SRFI 83 contain all messages, not just those from before July 7th, 2015.




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