module

declaration/definition

Syntax
module ( shared as (module identification)
          | interface shared as (module identification)
          | implements file-name)?


Purpose

An OmniMark module file begins with a module declaration. A file may contain only a single module.

A module is a component of OmniMark code that defines exactly what it allows access to (exports) in the code outside the module. A module may export record definitions, global variables and constants, or functions.

The keyword shared indicates a shared module. The module identification in a shared module declaration is used by OmniMark to determine whether or not the module has already been imported. Programmers should use different module identifications for different modules. These must be either a valid OmniMark name or a quoted string. You should try to use module identifications that are unlikely to be used by third party modules. Prefacing the name with your company's URL is a useful way of increasing the chance of uniqueness.

  module 
     shared as com.stilo.omnimark.omvfs

A module can also be declared to be an interface or implementation module. Normally a module specifies the interface and the implementation in a single file, but sometimes it is useful to separate the interface and the implementation.

An interface module specifies exactly what the implementation module is permitted to export. The interface contains only declarations, but no executable code (like function bodies or rules) or initial values (for variables or constants). The implementation module defines all of the functions, rules, and any variables which have initial values. This separation allows many implementation modules to be written to the same interface, promoting reusability.

To declare a module interface:

  module interface 
     shared as <module identifier>

When declaring an implementation module, refer to the matching inferface module:

  module 
     implements <interface module filename>

To import a module interface:

  import <module-file-name> [unprefixed | prefixed by <prefix>]

To import a module implementation:

  import <module-file-name> [unprefixed | prefixed by <prefix>]

The keywords interface and implements following the keyword module indicate the type of the module. A module which is split between interface and implementation is always a shared module.

The prefix declaration used to import the interface must match the prefix declared for the interface.