A module is a set of rules packaged in a membrane with a module name definition:

|{ module('''modulename'''), '''RuleSet''' }|

The RuleSet is made available only when it is copied or 'loaded' outside the membrane.  The module system of LMNtal provides a loading mechanism of modules.

A module can be defined either in the source file or in a separate file.  In the latter case, the module can be either in source code or in intermediate code.

**Name Space

A single-level global name space is available for the names of atoms. An atom name '''p''' can be qualified with a module name '''m'''. The qualified atom name '''m'''.'''p''' can be referred to anywhere in the program.

// Currently, we have no means to prevent a programmer from writing arbitrary qualified names, and we have no means to abbreviate the module name part of 'exported' names.

**Compile-Time Module Loading

When a program uses a qualified atom name of the form '''m'''.'''p''', the membrane that contains the qualified atom name will be supplied with a copy of the rules
specified in the module '''m'''.


 { module(acc).
   acc.add(A),   acc.value(N) :- acc.value(A+N).
   acc.get(Res), acc.value(N) :- int(N) | Res=N, acc.value(N).
   acc.new                    :- acc.value(0) }.
 { acc.new, acc.add(3), acc.add(4), acc.get(N) }

**Link-Time Module Loading

Modules defined in files in the $LMNTAL_HOME/installed/share/slim/lib directory or in the directories specified after the -I option of SLIM will be loaded, compiled (if not in the intermediate code) and linked before the exection of the user program starts.

***LMNtal Java

Link-time module lookup is performed when the source file does not contain the definition of a referenced module.  When a module '''m''' needs to be looked up, the file $LMNTAL_HOME/lib/src/m.lmn is loaded, compiled and linked before the execution of the user program starts, where $LMNTAL_HOME is the root directory of LMNtal.

**System rulesets

A '''system ruleset''' is a set of global rules, namely
rules applicable to every place in the membrane structure.
For instance, built-in arithmetics (that evaluates
x=1+2*3 to x=7, for example) is implemented as
system rulesets.

A programmer can define his/her own system ruleset by
defining the ''system_ruleset'' module.

//-There are three kinds of system rulesets:
//++Built-in system rulesets that cannot be modified by users
// ---Proxies for trans-membrane links fall into this category.
//---Currently, they are processed in InterpretedRuleset
//even when the translator is used.
//++Built-in system rulesets that are described in LMNtal and
//be modified
//---Arithmetics falls in this category, but the current implementation
//handles arithetics much like i.
//++LMNtal ?v???O??????????W???[???????????????isystem_ruleset?j

//i. ? ii. ??ATranslator ?????R???p?C????? runtiem.GlobalSystemRuleset
//??? iii. ??Aruntime.SystemRulesets ?N???X?????????B

Front page List of pages Search Recent changes Backup   Help   RSS of recent changes