## `export, unexport` -- export library functions or undo the export

#### Introduction

`export(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)`

#### Parameters

`L` | - | the library: a domain
`f1, f2, ...` | - | public functions of `L`: identifiers

#### Returns

the void object `null()` of type `DOM_NULL`.

#### Side Effects

When a function is exported, it is assigned to the corresponding global identifier. When it is unexported, the corresponding identifier is deleted.

#### Further Documentation

Chapter ``The MuPAD libraries'' of the Tutorial.

#### Related Functions

`:=`, `delete`, `info`, `loadmod`, `loadproc`, `package`, `unloadmod`

#### Details

- A library contains public functions which may be called by the user. The collection of these functions forms the interface of the library. (There may be other, private, functions, too, which are not intended to be called by the user directly, and are not documented.) The standard way of accessing the public function `f` 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`.

- On the other hand, unexporting the library function `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`.

- A function that is already exported will not be exported twice. A warning is printed instead.

- `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.

- The function `info` displays the interface functions and the exported functions of a library.

- Some libraries have functions that are always exported. These functions cannot be unexported. The function `append` from the library `listlib` is such an example.

  Most functions of the standard library `stdlib` are exported automatically.

#### Example 1

We 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 2

`export` 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.

#### Background

- The names of the public functions of a library `L` are stored in the set `L::interface`. This set is used by the function `info` and for exporting.

- The names of functions exported from a library `L` are stored in the set `L::exported`.

#### Changes

- `unexport` is a new function.

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000