Options for Modules
Calling Sequence
Parameters
Description
Examples
option opt1, opt2, ...
options opt1, opt2, ...
opt1, opt2, ...
-
symbols or equations for options
As with procedures, modules accept option declarations. An option is declared at the beginning of a module definition by the option declaration, which begins with the keyword option (or, equivalently, options) and is followed by an expression sequence of one or more options. Each option opt1, opt2, ... must either be a symbol or an equation whose left-hand side is a symbol.
An option whose meaning is not known to the system is ignored. This allows you to use options for your own purposes; they are equivalent to attributes and are accessible as such.
The only standard options that are meaningful for both procedures and modules are the trace and copyright options. In particular, the options remember, system, arrow, operator, and inline have no meaning for modules.
Only four options have a predefined meaning for modules. One is the module initialization option that takes the form load = pname, where pname is the name of a procedure found among the declared exports or locals of the module. If this option is present, then this procedure is called when the module is read from the Maple repository in which it is found.
Modules with option package are understood by the system to represent Maple packages. A module that is created with option package has its exports automatically protected.
The option record is used to identify records. Records are produced by the Record constructor and are represented using modules.
The unload = pname and load = lname options specifies the name of a local or exported procedure of the module that is to be called when the module is destroyed or loaded from a repository. These options mirror the functionality provided by the ModuleLoad and ModuleUnload commands.
u ≔ module...end module:
v ≔ module_export⁡e;_local⁡lend module:
interface⁡verboseproc=1:
print⁡u
moduleexporte;...end module
print⁡v
modulelocall;exporte;end module
This module is initialized by calling the procedure startup when the module is read from a repository. It executes the procedure shutdown when the module is either garbage collected or when Maple exits.
P := module() export e; local T, startup, shutdown; option load = startup, unload = shutdown; e := proc( n::posint ) if assigned( T[ n ] ) then T[ n ] else int( expr, x ) end if end proc; startup := proc( ) # store common values local i, expr; global x; for i from 1 to 100 do expr := sin( n * x ) * cos( n * x ); T[ expr, x ] := int( expr, x ) end do end proc: shutdown := proc( ) # print a message printf("Module P is going away\n"); end proc: end module:
This module has its exports protected automatically.
m ≔ moduleoptionpackage;_export⁡eend module
m ≔ moduleoptionpackage;exporte;end module
type⁡m:-e,protected
true
Module exports are not protected in the absence of the package option.
m ≔ module_export⁡eend module
m ≔ moduleexporte;end module
false
See Also
module
module/package
ModuleApply
ModuleLoad
ModulePrint
ModuleUnload
Procedure options
Record
Download Help Document