## `expose` -- display the source code of a procedure or the entries of a domain

#### Introduction

`expose(`f`)` displays the source code of the MuPAD procedure `f` or the entries of the domain `f`.

#### Call(s)

`expose(f)`

#### Parameters

`f` | - | any object; typically, a procedure, a function environment, or a domain

#### Returns

- If `f` is a procedure, `expose` returns the complete source code of `f`, of type `stdlib::Exposed` (see ``Background'' below).

- If `f` is a function environment, the result of applying `expose` to the first operand is returned.

- If `f` is a domain, `expose` returns a symbolic call to `newDomain`; see below for details.

- In all other cases, `expose` returns `f` if it is not overloaded.

#### Side Effects

The formatting of the output of `expose` is sensitive to the environment variable `TEXTWIDTH`.

### Overloadable:

`f`

#### Related Functions

`print`

#### Details

- Usually, procedures and domains are printed in abbreviated form. `expose` serves to display the complete source code of a procedure and all entries of a domain, respectively.
- If `f` is a domain, then `expose` returns a symbolic `newDomain` call. The arguments of the call are equations of the form `index = value`, where `value` equals the value of `f::index`. `expose` is not recursively applied to `f::index`; hence, the source code of domain methods is not displayed.
- Although `expose` returns a syntactically valid MuPAD object, this return value is intended for screen output only, and further processing of it is deprecated.

#### Example 1

Using `expose`, you can inspect the source code of procedures of the MuPAD library:

    >> sin

                                        sin

    >> expose(%)

          proc(x)
            name sin;
            local f, y;
            option noDebug;
          begin
            if args(0) = 0 then
              error("no arguments given")
            else
            ...
          end_proc

#### Example 2

On the other hand, you cannot look at the source code of kernel functions:

    >> expose(_plus)

                          builtin(817, NIL, "_plus", NIL)

#### Example 3

When applied to a domain, `expose` shows the entries of that domain:

    >> expose(DOM_INT)

          newDomain("coerce" = proc DOM_INT::coerce(x) ... end,

             "phi" = phi, "new_extelement" =

             proc new_extelement(d) ... end, "new" = proc new() ... end,

             "D" = 0, "key" = "DOM_INT")

#### Example 4

Applying `expose` to other objects is legal but generally useless:

    >> expose(3)

                                         3

#### Background

- In addition to the usual `overloading` mechanism for domain elements, a domain method overloading `expose` must handle the following case: it will be called with zero arguments when the domain itself is to be exposed.

- If `f` is a procedure, then `expose` returns an object of the domain `stdlib::Exposed`. The only purpose of this domain is its `"print"` method; manipulating its elements should never be necessary. Therefore it remains undocumented.

#### Changes

- The return value of `expose` is now of the new type `stdlib::Exposed` if the argument is a procedure.

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