This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Data type of procedure environments


Procedure environments are mostly ephemeral objects and are only rarely seen by the user (and even more rarely useful to examine). A procedure environment represents a procedure that is currently being executed: formal parameters and local variables have values.

Procedure environments do rarely become visible, and you do not need to manipulate them directly. They serve only one purpose: if a procedure is generated inside another procedure, variable names in the body of the inner procedure that are not declared local there refer to names in the outer procedure, provided they are declared local in the outer procedure. (See the Programming Manual for more information on the scoping rules for MuPAD®.) Consequently, the inner procedure must contain information on the current values of local variables of the outer procedure. Hence, the status of the outer procedure is encoded into an object of type DOM_PROC_ENV, and that object is stored in the returned procedure as its twelfth operand.

You never need to generate objects of this type. There are no operations available.


Example 1

The only occasion on which you should come across a procedure environment is the following: an outer procedure returns an inner procedure depending on formal parameters or local variables of the outer procedure:

outer := 
option escape;
  /* inner procedure to return : */
  y -> x + y
add5 := outer(5)

In spite of the (slightly confusing) output, x has a special meaning here: it points to the parameter x of outer. That parameter currently has the value 5 and won't be changed any more. To be able to access that value, the particular instance of outer in the status of being executed has to be stored in add5:

expr2text(op(add5, 12))


The number of operands of a procedure environment depends on the number of local and saved variables of the outer procedure. Details about the operands remain undocumented.


The integers appearing in the output of objects of type DOM_PROC_ENV have no mathematical meaning; they denote positions in memory.

Was this topic helpful?