<< Prev | - Up - | Next >> |
Not only can you create functors interactively, but you can also save them in files. We call this ``making functors persistent''. Consider our earlier functor Foo
. We can save it to file /tmp/Foo.ozf
as follows:
{Pickle.save Foo "/tmp/Foo.ozf"}
A persistent value is also called a pickle, hence the name Pickle
for the module providing the API for persistent values. Note the extension ozf
for the file in which we saved our functor: this is the extension conventionally chosen for persistent functors. The advantage of a persistent functor is that it can be reused:
declare [M]={Module.link ['/tmp/Foo.ozf']}
{M.greet}
Even more interestingly, it can be reused as an import in an other module:
declare
functor Baz
import GreetModule at '/tmp/Foo.ozf'
export GreetTwice
define
proc {GreetTwice}
{GreetModule.greet}
{GreetModule.greet}
end
end
declare [M]={Module.apply [Baz]}
{M.greetTwice}
<< Prev | - Up - | Next >> |