Opened 5 years ago

Closed 5 years ago

#353 closed defect (fixed)

No use before import in libraries

Reported by: cowan Owned by: cowan
Priority: major Milestone:
Component: WG1 - Core Keywords:


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):

  (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.

Change History (4)

comment:1 Changed 5 years ago by cowan

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

comment:2 Changed 5 years ago by cowan

  • Status changed from new to decided

WG1 decided to adopt this limitation.

comment:3 Changed 5 years ago by cowan

  • Owner changed from alexshinn to cowan
  • Status changed from decided to writing

comment:4 Changed 5 years ago by cowan

  • Resolution set to fixed
  • Status changed from writing to closed
Note: See TracTickets for help on using tickets.