Module Options - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Programming : Modules : Module Options

Options for Modules


Calling Sequence




Calling Sequence

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.


umodule...end module:

vmodule_exporte;_locallend module:



moduleexporte;...end module



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 ]
            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;_exporteend module

mmoduleoptionpackage;exporte;end module





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

mmodule_exporteend module

mmoduleexporte;end module





See Also







Procedure options