export, unexport -- export
library functions or undo the export
Introductionexport(L, f) exports the public function
L::f of the library L, such that it can be
accessed as f, without the prefix L.
export(L) exports all public functions of the library
L.
unexport(L, f) undoes the export of the public function
L::f of the library L, such that it is no
longer available as f.
unexport(L) undoes the export of all previously
exported public functions of the library L.
Call(s)export(L, f1, f2, ...)
export(L)
unexport(L, f1, f2, ...)
unexport(L)
ParametersL |
- | the library: a domain |
f1, f2, ... |
- | public functions of L: identifiers |
Returnsthe void object null()
of type DOM_NULL.
Side
EffectsWhen a function is exported, it is assigned to the corresponding global identifier. When it is unexported, the corresponding identifier is deleted.
Further
DocumentationChapter ``The MuPAD libraries'' of the Tutorial.
Related
Functions:=, delete, info, loadmod, loadproc, package, unloadmod
Detailsf from the library L is via
L::f. When the function f is
exported, it can be accessed more briefly as f.
Technically, exporting means that the global identifier f
is assigned the value L::f.f
means that the value of the global identifier f is
deleted. Afterwards, the library function is available only as
L::f.export(L, f1, f2, ...) exports the given functions
f1, f2, ... of L. However, if one of the
identifiers already has a value, the corresponding function is not
exported. A warning is printed instead. An error is returned if one of
the identifiers is not the name of a public library function.export(L) exports all public functions of
L.unexport(L, f1, f2, ...) unexports all given functions
of L. Note that unexport does not evaluate
the identifiers. Thus, it is not necessary to use hold to protect them from being
evaluated.unexport(L) unexports all public functions of the
library L.export and unexport evaluate their first
argument L, but they do not evaluate the remaining
arguments f1, f2, ..., if any.info
displays the interface functions and the exported functions of a
library.append from the library listlib is such an example.
Most functions of the standard library stdlib are exported
automatically.
Example
1We export the public function powerset of
the library combinat
and then undo the export:
>> combinat::powerset(2)
{{}, {2}, {1}, {1, 2}}
>> export(combinat, powerset):
>> powerset(2)
{{}, {2}, {1}, {1, 2}}
>> unexport(combinat, powerset):
>> powerset(2)
powerset(2)
We export and unexport all public functions of the
library combinat:
>> export(combinat): permute([1, 2])
[[1, 2], [2, 1]]
>> unexport(combinat): permute([1, 2])
permute([1, 2])
Example
2export issues a warning if a function
cannot be exported since the corresponding identifier already has a
value:
>> powerset := 17: export(combinat, powerset)
Warning: 'powerset' already has a value, not exported.
A function will not be exported twice, and
export issues a corresponding message if you try:
>> delete powerset: export(combinat, powerset): export(combinat, powerset): unexport(combinat, powerset):
Info: 'combinat::powerset' already is exported.
BackgroundL are
stored in the set L::interface. This set is used by the
function info and for
exporting.L are
stored in the set L::exported.unexport is a new function.