SHARED

SHARED [ VIRTUAL ] definition

VIRTUALOptional. Specifies the definition is VIRTUAL. Valid only inside a MODULE Structure.
definitionA valid definition.

The SHARED keyword explicitly allows other definitions within the same folder to import the specified definition for use throughout the module/folder/directory (i.e. module scope), but not outside that scope.

ECL code is stored in .ecl text files which may only contain a single EXPORT or SHARED definition. This definition may be a structure that allows EXPORT or SHARED definitions within their boundaries (such as MODULE, INTERFACE, TYPE, etc.). The name of the .ecl file containing the code must exactly match the name of the single EXPORT (or SHARED) definition that it contains.

Definitions without the EXPORT or SHARED keywords are local to the file within which they reside (see Definition Visibility). A local definition's scope is limited to the next SHARED or EXPORT definition, therefore they must precede that file's EXPORT or SHARED definition.

Example:

//this code is contained in the GoodHouses.ecl file
BadPeople := Person(EXISTS(trades(EXISTS(phr(phr_rate > '4'))));
        //local only to the GoodHouses definition
SHARED GoodHouses := Household(~EXISTS(BadPeople));
        //available all thru the module

//and in AnotherDef.ecl we have this code:
EXPORT AnotherDef := MODULE(x)
  EXPORT INTEGER a := c * 3;
  EXPORT INTEGER b := 2;
  SHARED VIRTUAL INTEGER c := 3; //this def is VIRTUAL
  EXPORT VIRTUAL INTEGER d := c + 3; //this def is VIRTUAL
  EXPORT VIRTUAL INTEGER e := c + 3; //this def is VIRTUAL
END;

See Also: IMPORT, EXPORT, Definition Visibility, MODULE Structure