This site is a static rendering of the Trac instance that was used by R7RS-WG1 for its work on R7RS-small (PDF), which was ratified in 2013. For more information, see Home.

Ticket 353: No use before import in libraries

2012-10-07 04:35:07
WG1 - Core
2012-02-26 18:25:44

For ease of implementation, I think we should make it an error for an imported identifier to be referenced or defined in a library before the library declaration that imports it. This allows strict left-to-right processing of library declarations, with no need to delay processing till the end of the library.

Therefore, this would be an error (but still permitted as an extension in Schemes that can easily provide it):

(module (begin (define x y)) (import (library defining y))

This would necessitate replacing the penultimate paragraph of section 5.5.1 with:

One possible implementation of libraries is as follows: After all cond-expand library declarations are expanded, a new environment is constructed for the library consisting of all imported bindings. The expressions and declarations from all begin, include, and include-ci declarations are expanded in that environment in the order in which they occur in the library declaration. Alternatively, cond-expand and import declarations may be processed in left to right order interspersed with the processing of expressions and declarations, with the environment growing as imported bindings are added to it by each import declaration.

Incremental processing is the way Chicken modules (which are just name scopes) work today, and it seems a plausible approach to allow.


WG1 decided to adopt this limitation.