ModulesA module is a set of rules packaged in a membrane with a module name definition:
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 SpaceA 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. Compile-Time Module LoadingWhen 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. Example{ 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 LoadingModules 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. System rulesetsA 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. |