Node:Modules, Previous:Exporting declarations, Up:Declarations
(NOTE: WORK IN PROGRESS)
A Q program can either be typed in as interactive commands, or can be read from a file. A Q program in a file should have the form of an exporting block. Such a program is called a module. (By the way, a session of interactive commands is also a kind of module.)
You can "load" in a module either by naming it on
the command line, or by using a load
command.
load module_name | Function |
Note: the module_name is quoted. |
The named module is searched for (using search rules
not yet specified). The searching can resolve to
a source file or a binary (previously compiled) file.
Either way, the value resulting from the load
is (normally?) a record.
Loading a module involved a number of steps. If the module_name is a plain identifier or simple quoted string literal, then the initial parts of loading is done at parse time. This is normally the case. It is also required when there a several modules that mutually reference each other.
Loading a source files includes parsing,
tree-traversal, and evaluation.
If the module_name is known, then
the module is parsed just after the load
is parsed, and tree-traversal is done at the
same time as for the module containing the load
.
In that case, the names exported by the module
are known early, and the names can be inherited
int some other block. Otherwise, all of the actions
have to be postposed until evaluation time,
and the type of the module is unknown until then.
Loading a binary file includes reading in the text and data segments, remembering the labels defined and needed, performing relocation, and running initialization code. If the module_name is known, most of these steps can be done at parse time.