module - Maple Help

type/module

check for a module

type/record

check for a record

 Calling Sequence type(expr, 'module') type(expr, 'module'(e1, e2, ..., en)) type(expr, 'record') type(expr, 'record'(e1, e2, ..., en))

Parameters

 expr - any expression ei - names of expected exports

Description

 • The command type(expr, 'module') returns true if expr is of type module. Otherwise, false is returned.
 Expressions of type module are created as a result of evaluating a module definition.
 • When called with optional arguments ei ($i=1..n$), the command returns true if, in addition to being of type module, the module e exports members named e1, e2, ..., en. It is not required that e1, e2, ..., en name all the exports of the module, only that each among them appears as an export. (Note carefully the type and placement of quotes in the Examples section below.)
 • The optional exports ei can be either symbols or expressions of the form symbol :: type. If a type specifier appears, then the module expr must export the given name with an assigned value of the given type. For instance, the type module( x :: posint ) describes a module with an export named x currently assigned a value of type posint.
 • The first optional export, e1, can also be a string. In that case, the module expr must be a named module whose name matches (textually) e1.
 • Note: Because the name module is a Maple keyword, it must be enclosed in back quotes when used as an argument to type. Failure to do so results in a syntax error.
 • The type record is identical to type module, except that it recognizes modules that are records, returning false for modules that are not records. (See Record.)

Subtypes

 •

Supertypes

 •

Examples

 > $\mathrm{type}\left(\mathrm{LinearAlgebra},'\mathrm{module}'\right)$
 ${\mathrm{true}}$ (1)
 > $\mathrm{type}\left(\mathbf{module}\left(\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end module},\mathrm{module}\right)$
 ${\mathrm{true}}$ (2)
 > $\mathrm{type}\left('\mathbf{module}\left(\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end module}',\mathrm{module}\right)$
 ${\mathrm{false}}$ (3)
 > $\mathrm{type}\left(2,'\mathrm{module}'\right)$
 ${\mathrm{false}}$ (4)
 > $\mathrm{type}\left(\mathrm{sin},'\mathrm{module}'\right)$
 ${\mathrm{false}}$ (5)
 > $m≔\mathbf{module}\left(\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{_export}\left(\mathrm{e1},\mathrm{e2}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end module}:$
 > $\mathrm{type}\left(m,'\mathrm{module}'\right)$
 ${\mathrm{true}}$ (6)
 > $\mathrm{type}\left(m,'\mathrm{module}\left(\mathrm{e1}\right)'\right)$
 ${\mathrm{true}}$ (7)
 > $\mathrm{type}\left(m,'\mathrm{module}\left(\mathrm{e2}\right)'\right)$
 ${\mathrm{true}}$ (8)
 > $\mathrm{type}\left(m,'\mathrm{module}\left(\mathrm{e1},\mathrm{e2}\right)'\right)$
 ${\mathrm{true}}$ (9)
 > $\mathrm{type}\left(m,'\mathrm{module}\left(\mathrm{e1},\mathrm{e2},\mathrm{e3}\right)'\right)$
 ${\mathrm{false}}$ (10)
 > $q≔\mathrm{SimpleQueue}\left(\right):$
 > $\mathrm{type}\left(q,'\mathrm{module}\left(\mathrm{enqueue},\mathrm{dequeue}\right)'\right)$
 ${\mathrm{true}}$ (11)
 > $\mathrm{type}\left(m,'\mathrm{record}'\right)$
 ${\mathrm{false}}$ (12)
 > $r≔\mathrm{Record}\left('a'=2,'b'=3\right)$
 ${r}{≔}{\mathrm{Record}}{}\left({a}{=}{2}{,}{b}{=}{3}\right)$ (13)
 > $\mathrm{type}\left(r,'\mathrm{module}'\right)$
 ${\mathrm{true}}$ (14)
 > $\mathrm{type}\left(r,'\mathrm{record}'\right)$
 ${\mathrm{true}}$ (15)
 > $\mathrm{type}\left(r,'\mathrm{record}\left(a,b\right)'\right)$
 ${\mathrm{true}}$ (16)
 > $\mathrm{type}\left(r,'\mathrm{record}\left(a::'\mathrm{integer}',b\right)'\right)$
 ${\mathrm{true}}$ (17)
 > $\mathrm{type}\left(r,'\mathrm{record}\left(a::'\mathrm{integer}',b::\mathrm{float}\right)'\right)$
 ${\mathrm{false}}$ (18)
 > p := proc(x) local XYZ; module XYZ() export a; end module; XYZ:-a := x; XYZ end proc:
 > $\mathrm{m1}≔p\left(2\right)$
 ${\mathrm{m1}}{≔}{\mathbf{module}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{XYZ}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{export}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{a}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (19)
 > $\mathrm{m2}≔p\left(3.5\right)$
 ${\mathrm{m2}}{≔}{\mathbf{module}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{XYZ}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{export}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{a}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (20)
 > $\mathrm{type}\left(\mathrm{m1},'\mathrm{module}'\left(a::'\mathrm{integer}'\right)\right)$
 ${\mathrm{true}}$ (21)
 > $\mathrm{type}\left(\mathrm{m1},'\mathrm{module}'\left("XYZ"\right)\right)$
 ${\mathrm{true}}$ (22)
 > $\mathrm{type}\left(\mathrm{m1},'\mathrm{module}'\left("XYZ",a::'\mathrm{integer}'\right)\right)$
 ${\mathrm{true}}$ (23)
 > $\mathrm{type}\left(\mathrm{m2},'\mathrm{module}'\left("XYZ"\right)\right)$
 ${\mathrm{true}}$ (24)
 > $\mathrm{type}\left(\mathrm{m2},'\mathrm{module}'\left("XYZ",a::'\mathrm{integer}'\right)\right)$
 ${\mathrm{false}}$ (25)