Documentation Center

  • Trial Software
  • Product Updates


Create a transparent block with some identifiers protected against evaluation

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.




blockIdents(S)(a) creates a transparent block which is evaluated like a, except that the identifiers in S are neither substituted by their values nor are their properties used.

blockIdents is a parametrized family of domains, depending on a parameter S which must be a set. If d is any block domain, d(a) creates a block belonging to that domain, with content a.

blockIdents(S)(a) replaces all identifiers in a that belong to S by newly created identifiers, evaluates the result and substitutes back; the final result is put into a block. In order to evaluate a normally before putting it into a block, useeval(hold(blockIdents(S))(a)).

Blocks of type blockIdents(S) are evaluated in the same way as their contents at the time of creation (see above).

Blocks of type blockIndents(S) have the same operands as their content.

Sequences can also be put into blocks.

You can create further block domains using inheritance. This particularly useful for creating own evaluate or testtype methods. See Example 6.

The call expr(b) replaces all transparent blocks in b by their content, without evaluating that content.

In case of nested blocks, only the outermost block is removed by both expr and unblock.


Example 1

A block is a sort of container that protects its content against evaluation:

y:= 1: bl:= block(1+y)

Blocks are atomic; thus y and 1 are not visible as operands:

op(bl), nops(bl)

Although blocks are not arithmetical expressions, some basic arithmetical operations are defined for them:

collect(x+bl+x*bl, bl);
delete y, bl:

Example 2

Transparent blocks protect against evaluation, too:

y:= 2:

However, a transparent block allows access to the operands of its content:

op(bl,1), subs(bl, hold(y) = y)

delete bl, y:

Example 3

With a third kind of block, suppressing evaluation may be limited to certain identifiers:

x:= 3: y:=1:

delete x, y:

Example 4

A block may also contain a sequence; flattening is suppressed:

block((x, y),z)

Example 5

The content of a block may be extracted and evaluated using unblock:

y:= 1: unblock(block(y)); delete y:

Example 6

We want to create blocks that represent arithmetical expressions. To do this, we need our own block domain that overloads testtype:

domain myblock 
  inherits block; 
  category  Cat::BaseCategory;
  testtype:= (bl, T) -> if T = Type::Arithmetical or T = dom then 
                          block::testtype(bl, T) 

This allows us to make the number zero invisible for the evaluator by enclosing it into a block, but to retain the option to plug it into special functions:

f := sin(x+myblock(0))

We can now manipulate this expression, without being disturbed by automatic simplification:





Any object or sequence of objects


Set of identifiers

Return Values

blockIdents creates objects of its own type.

See Also

MuPAD Functions

Was this topic helpful?