- Up - | Next >> |
In Mozart, modules of the base environment are loaded on need only. For observing this, start a fresh Mozart system and execute:
{Browse FD}
If your Mozart is really fresh than the Browser displays
FD:Future
meaning that the variable FD
will be bound to the FD-module once it is needed in the future. This mechanism is called lazy loading.
The idea of lazy loading is as follows: When the Mozart system comes up then not all modules are automatically loaded in order to speed up the start-up time. However, there already exists a propagator in the system, who knows a web-address or a directory from where to import the value of FD
. Once the value of FD
is needed, this propagator becomes active and binds FD
to the FD-module.
There are several ways of expressing the need of a value. For instance,
{Wait FD}
waits until the future value of the variable FD
is known and loads its value. In a fresh programming environment, the future value of FD
is known to be the finite domain module. Thus {Wait FD}
simply leads to loading the finite domain module. Another way of expressing the need of FD
is by selection a feature from the module, such as by executing FD.decl
.
For programming with functors, a programmer has to know the names of the standard modules he uses. For instance, the procedure Browse
is imported by the module Browser
of the base environment.
{Browser.browse 'Browse belongs module Browser'}
The procedure Show
belongs to the module System
of the base environment.
{System.show 'Show belongs to the module System'}
In Mozart, you can also write your own modules that are loaded lazily by using the syntax for describing functors.
- Up - | Next >> |