<<'one.pkg'; -- read in the package
Test(1); -- error here because the function 'Test' is not defined
-------------------------------
ERROR: Unknown operator Test
CONTEXT: Test(1)
-------------------------------
$contrib/toypackage.Test(1); -- this is the name of the function
-- we are looking for
The number 1.
-------------------------------
Alias Toy := $contrib/toypackage; -- use an alias to save typing
Toy.Test(3);
Not the number 1.
-------------------------------
Toy.IsOne(3);
FALSE
-------------------------------
Once the package is read, the user can choose a "substitute prefix"
using the 'Alias' command and in that way avoid conflicts between
functions in various packages and save on typing.
Note one other thing: the function 'IsOne' is used in the definition
of 'Test'. In that case, it is referred to as '$.IsOne'. Otherwise,
CoCoA would look for a global function, outside of the package, called
'IsOne'. Forgetting this kind of reference is a common source of
errors when constructing a package.
|