Options for Modules - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Procedures and Functions : options : module/option

Options for Modules

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

option opt1, opt2, ...

options opt1, opt2, ...

Parameters

opt1, opt2, ...

-

symbols or equations for options

Description

• 

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.

Examples

umoduleexporte;...end module:

vmodulelocall;exporte;end module:

interface'verboseproc'=1:

printu

moduleexporte;...end module

(1)

printv

modulelocall;exporte;end module

(2)

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.

mmoduleoptionpackage;exporte;end module

m:=moduleoptionpackage;exporte;end module

(3)

typem:-e,'protected'

true

(4)

Module exports are not protected in the absence of the package option.

mmoduleexporte;end module

m:=moduleexporte;end module

(5)

typem:-e,'protected'

false

(6)

See Also

module

module/package

ModuleApply

ModuleLoad

ModulePrint

ModuleUnload

Procedure options

Record

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam