> > Functors can have external references and can be created at
> > run-time, just like all other data types. This allows to
> > parameterize them. Here's a pretty useless example, but it shows
> > the point:
> >
> > fun {NewAdder N}
> > functor
> > export inc:Inc
> > define
> > fun {Inc X} X+N end
> > end
> > end
> >
> > % Create a software component parameterized by '5':
> > F={NewAdder 5}
> >
> > The documentation speaks of 'computed functors'; these are just
> > syntactic sugar for the above technique.
>
> This doesn't seem to allow separate compilation (at least at the same
> time as sharing the module's parameter). As I mentioned, PLT units
> allow external references, but it's not as useful as having parametric
> modules.
Actually, separate compilation is not a problem, because functors are
just values. These values can be created by the compiler or by the
interactive interface; it's the same thing. Dynamic linking is just a
case of loading the functor and installing it, which creates the module.
Because of logic variables, functors are completely decoupled from each
other and can be compiled separately, even if they have shared
references. For example, consider mutually recursive modules. A variable
can reference a module even though the module does not yet exist in the
system (the variable exists but is unbound). This means that modules can
be mutually recursive, as long as the recursion bottoms out at run-time.
If a module is referenced at run-time, and it has not yet been created,
then its functor is loaded and installed dynamically, creating the module.
This done using lazy evaluation to bind the logic variables when their
values are needed.
> (BTW, I'm curious, why are they called functors in Oz?)
I'm not sure, I think it is because of the inspiration from ML functors.
Someone else might be able to answer this!
> Mark Seaborn
About the rest of your message: there's a lot there, let me digest it
before comparing with functors!
Regards,
Peter Van Roy
-
Please send submissions to users@mozart-oz.org
and administriva mail to users-request@mozart-oz.org.
The Mozart Oz web site is at http://www.mozart-oz.org/.