Download Maple Advanced Programming Guide

Transcript
84
• Chapter 2: Programming with Modules
argument:
> savelib( ’LinkedList’ );
Evaluating the savelib call saves the module to the first repository
found in the global variable libname, or the repository named with the
global variable savelibname, if it is defined. (At least one of these must
be defined.)
Important Always ensure that the standard Maple library is writeprotected to avoid saving expressions in it. If you accidentally save something to the standard Maple library, you may need to restore the original
from the media on which you obtained the Maple software.
The package exports are listed as the exports of the module. A few
local variables are used to implement the package. The local procedures
map1 and reverse1 are part of the package implementation that is not
available to users of the package. They are visible only within the module
definition. This allows the package author to make improvements to the
package without disturbing any code that uses it. If the local procedures
reverse1 and map1 were exported (thus, available to users), it would be
difficult for the author to replace these routines without breaking existing
code that relies upon them.
The package includes two special (local) procedures, setup and
cleanup. These are executed, respectively, when the module is first read
from a repository, and when the package is either garbage collected or
when Maple is about to exit.
Using the Package The package exports can always be accessed by
using the long form of their names.
> LinkedList:-pair( a, b );
(a, b)
For consistency with the older table-based package implementations,
an indexed notation can also be used.
> LinkedList[ ’pair’ ]( a, b );
(a, b)