<< Prev | - Up - | Next >> |
Write a file SetAbs.oz
containing a functor program for the set abstract datatype that you previously developed in an exercise (see Section 7.11). The functor should export the constructor procedure on feature new
. Install ozmake
on your computer and use it to compile SetAbs.oz
to produce SetAbs.ozf
. The shell command to achieve this is:
ozmake --build SetAbs.ozf
or more simply:
ozmake SetAbs.ozf
Verify that this worked by obtaining the SetAbs
module in the OPI from file SetAbs.ozf
using Module.link
. Create a set. Add some elements. Check for membership, etc.
Use ozmake
to remove the compiled file SetAbs.ozf
from your project directory. This can be achieved with the command:
ozmake --clean
Now write a makefile in file makefile.oz
to describe this library. The library SetAbs.ozf
should be installed at the abstract URI x-ozlib://oz-kurs/exercises/SetAbs.ozf
(think what is the value of the makefile's uri
feature needed in order to achieve this). The package offering this library should be identified by mogul:/oz-kurs/exercises/modprog
(note that mogul:
here is part of this abstract identifier, just like x-ozlib:
above is part of the librarie's abstract URI). Invoke ozmake
in order to build and install your package. The command for this is:
ozmake --install
You should now list the contents of your database of installed packages as follows:
ozmake --list
Now test that this worked by obtaining the SetAbs
module in the OPI from its abstract URI:
declare [MySetModule] = {Module.link ['x-ozlib://oz-kurs/exercises/SetAbs.ozf']}
Create a set. Add some elements, etc.
Rewrite the finite automaton code of Section 6.2 into a functor program FiniteAutomaton.oz
which exports on feature accept
one function:
fun {Accept Automaton Word} ... end
This function takes an Automaton
as 1st argument and a Word
as 2nd argument and returns true iff the Word
is accepted by the Automaton
. Your functor should import the library x-ozlib://oz-kurs/exercises/SetAbs.ozf
that you installed in the previous exercise and use this abstraction in its code. Extend makefile.oz
to state that FiniteAutomaton.ozf
is also part of your package. Compile and install your package using the command:
ozmake --upgrade
what happens if instead you invoke ozmake --install
and why? Test that your library works by getting your new FiniteAutomaton
module with Module.link
in the OPI. What is its abstract URI? Use it in the argument to Module.link
. Test FiniteAutomaton.accept
with some examples.
Create a package file modprog.pkg
for this little project. This is achieved with command:
ozmake --create --package=modprog.pkg
Verify that this worked by installing the package you just created:
ozmake --upgrade --package=modprog.pkg
Why do we use option --upgrade
rather than --install
? Now uninstall the package:
ozmake --uninstall --package=mogul:/oz-kurs/exercises/modprog
Why is the package argument here mogul:/oz-kurs/exercises/modprog
rather than modprog.pkg
? Verify that the library provided by the package is no longer available by attempting to obtain and use it in the OPI. Install it again from modprog.pkg
and very that it is again available and works.
<< Prev | - Up - | Next >> |