MODULE Structure

modulename [ ( parameters ) ] := MODULE [ ( inherit ) ] [, VIRTUAL ] [, LIBRARY(interface) ] [, FORWARD ]

members;

END;

modulenameThe ECL definition name of the module.
parametersOptional. The parameters to make available to all the definitions.
inheritA comma-delimited list of INTERFACE or abstract MODULE structures on which to base this instance. The current instance inherits all the members from the base structures. This may not be a passed parameter.
membersThe definitions that comprise the module. These definitions may receive parameters, may include actions (such as OUTPUT), and may use the EXPORT or SHARED scope types. These may not include INTERFACE or abstract MODULEs (see below). If the LIBRARY option is specified, the definitions must exactly implement the EXPORTed members of the interface.
VIRTUALOptional. Specifies the MODULE defines an abstract interface whose definitions do not require values to be defined for them.
LIBRARYOptional. Specifies the MODULE implements a query library interface definition.
interfaceSpecifies the INTERFACE that defines the parameters passed to the query library. The parameters passed to the MODULE must exactly match the parameters passed to the specified interface.
FORWARDOptional. Delays processing of definitions until they are used. Adding ,FORWARD to a MODULE delays processing of definitions within the module until they are used. This has two main effects: It prevents pulling in dependencies for definitions that are never used and it allows earlier definitions to refer to later definitions. Note: Circular references are still illegal.

The MODULE structure is a container that allows you to group related definitions. The parameters passed to the MODULE are shared by all the related members definitions. This is similar to the FUNCTION structure except that there is no RETURN.

Definition Visibility Rules

The scoping rules for the members are the same as those previously described in the Definition Visibility discussion:

  • Local definitions are visible only through the next EXPORT or SHARED definition (including members of the nested MODULE structure, if the next EXPORT or SHARED definition is a MODULE).

  • SHARED definitions are visible to all subsequent definitions in the structure (including members of any nested MODULE structures) but not outside of it.

  • EXPORT definitions are visible within the MODULE structure (including members of any subsequent nested MODULE structures) and outside of it .

Any EXPORT members may be referenced using an additional level of standard object.property syntax. For example, assuming the EXPORT MyModuleStructure MODULE structure is contained in an ECL Repository module named MyModule and that it contains an EXPORT member named MyDefinition, you would reference that definition as MyModule.MyModuleStructure.MyDefinition:

MyMod := MODULE
  SHARED x := 88;
  y := 42;
  EXPORT InMod := MODULE //nested MODULE
    EXPORT Val1 := x + 10;
    EXPORT Val2 := y + 10;
  END;
END;

OUTPUT(MyMod.InMod.Val1);
OUTPUT(MyMod.InMod.Val2);