Go to the first, previous, next, last section, table of contents.


Anticipated Questions

Q
Why aren't identifiers my module imports exported?
A
Collisions and unexpected interactions are much more likely with transitive importing. This sort of lossage often occurs when using C. Sometimes it is very difficult to find conflicting include files because the definitions from all subsidiary include file's accumulate. But you can explicitly export identifiers:
(export ... predict ...)        ; or no export statement.
(import-module (load-module "prognosticate.scm"))
(define predict predict)
Q
What if I want to import just one identifier from a module? Do I need to import the whole module? What if some identifier I import will occlude an already defined identifier?
A
(define antique:car (with-module antique-module car))
Q
If I should not export data types such as vectors, how can I access a table from a module? If I can't set an imported identifier, how can I change a shared resource?
A
Modifying the values or structure of exported identifiers directly might corrupt the module for another user, so it is an error to do so. The module author can provide a shared resource to importers by exporting identifiers bound to procedures which access and modify the shared resource.
Q
I think modules should not export top-level definitions by default. Wny does modulite do this?
A
The short answer is: so that existing unmodified Scheme files can be modules. If a module had no export statement and the default were to not export, then the module would be empty (no exports). An empty module has no effect -- it would serve only as a digital boat anchor. When a module is loaded which has no export statement, the only meaningful action to take is to export all top-level identifiers.
Q
How can I debug my module if I can't redefine identifiers in a module? Do I have to reload my whole program every time I trace a different procedure?
A
The only difference between creating a module and loading a Scheme file as you do now is the single call to load-module instead of load; all of the subsidiary files included in the module are brought in using load. Therefore, load rather than load-module the module you are debugging. Scheme code currently must avoid naming conflicts, so doing this with current code would not introduce new name collisions; Having more than one module loaded (rather than load-moduled) in the future will potentially introduce collisions.
Q
Why do you use files as the organizing structure for modules? What if I want to have several modules defined in one file? What if I want to define modules from an interactive session?
A
Files are already the organizing structure for load. The constructs make-module and module allow you to define any number of modules in a single file (or multiple files). If you want to interactively extend and modify modules from an interactive session, you will need a more powerful system. I believe the GUILE module system is capable of this. My reasons for not incorporating that capability in this Scheme module system are:


Go to the first, previous, next, last section, table of contents.