[Larceny-users] cyclic library dependency

William D Clinger will at ccs.neu.edu
Sun Jan 31 09:31:16 EST 2016


Alex Shinn wrote:

> Where does R6RS state it forbids cyclic libraries?

That's a consequence of R6RS Section 7.3, and is stated
a bit more directly in the (never-ratified) R6RS Rationale
Section 7.

What I'm about to quote is easier to understand if you recall
that, in the absence of macros, all variables are referenced
at phase 0.  From R6RS Section 7.3:

    If any of a library’s definitions are referenced at
    phase 0 in the expanded form of a program, then an
    instance of the referenced library is created for
    phase 0 before the program’s definitions and
    expressions are evaluated. This rule applies
    transitively: if the expanded form of one library
    references at phase 0 an identifier from another
    library, then before the referencing library is
    instantiated at phase n, the referenced library
    must be instantiated at phase n.

Note the word "must" in that last sentence.  Note also the
two uses of the word "before".  If some library B imports
another library A, then the above says library A "must" be
instantiated "before" library B is instantiated.

A library can't be instantiated at level 0 before it is
instantiated at level 0, so cyclic library dependencies
are forbidden by the R6RS absolute requirement ("must")
quoted above.

The R6RS Rationale Section 7 says:

    The library system does not address the following
    goals, which were considered during the design
    process:

      * independent compilation
      * mutually dependent libraries
      * separation of library interface from library
        implementation
      * local modules and local imports

The only one of those four that is clearly forbidden by
an absolute requirement of the R6RS is the second one:
mutually dependent libraries.

Will



More information about the Larceny-users mailing list