Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Modules

dexport (definition+export operator)

Arguments < value: Value < name: Identifier

The dexport primitive token binds and exports a name-value pair. It is a convenience feature that has identical behavior to <name> globaldef <name> export.

The runtime behavior of dexport is as follows:

  1. Store the (name, value) binding in the global nametable.
  2. Export the (name, value) binding from the current module.

export

Arguments < name: Identifier

The export primitive token exports the value bound to the name in the module namespace.

The runtime behavior of export is as follows:

  1. Lookup the value associated with the given name in the current scope.
  2. Export the (name, value) binding obtained in the previous step from the current module.

use (import module)

Arguments < module name: String

The use primitive token is used to import a module.

The runtime behavior of use is as follows. For the purposes of this description, “source module” refers to the module that contains the use PT in question, and “target module” refers to the module being imported.

  1. Resolve the target module named by the given module name, using the module resolution algorithm. The result of module name resolution is an unambiguous file system path.
  2. Load the SOF source file from the file system path determined in the previous step, and propagate any errors. This step MAY be cached.
  3. Place a nametable on top of the stack.
    • This nametable will be referred to as the “module” nametable.
    • For the remainder of the execution of the target module, the module nametable functions as the global nametable. Any specification referencing the global nametable therefore references the module nametable while the module is being executed.
  4. Execute the token list of the target module’s source file.
  5. Remove the module nametable from the stack, as well as all tokens above it.
  6. Import all names into the source module which were exported from the target module.