Function: block ([<v_1>, ..., <v_m>], <expr_1>, ..., <expr_n>)
Function: block (<expr_1>, ..., <expr_n>)
block evaluates <expr_1>, ..., <expr_n> in sequence and returns the value of the last expression evaluated. The sequence can be modified by the
return functions. The last expression is <expr_n> unless
return or an expression containing
throw is evaluated. Some variables <v_1>, ..., <v_m> can be declared local to the block; these are distinguished from global variables of the same names. If no variables are declared local then the list may be omitted. Within the block, any variable other than <v_1>, ..., <v_m> is a global variable.
block saves the current values of the variables <v_1>, ..., <v_m> (if any) upon entry to the block, then unbinds the variables so that they evaluate to themselves. The local variables may be bound to arbitrary values within the block but when the block is exited the saved values are restored, and the values assigned within the block are lost.
local(<v_1>, ..., <v_m>) within
block saves the properties associated with the symbols <v_1>, ..., <v_m>, removes any properties before evaluating other expressions, and restores any saved properties on exit from the block. Some declarations are implemented as properties of a symbol, including
assume, and some others. The effect of
local is to make such declarations effective only within the block; otherwise declarations within a block are actually global declarations.
block may appear within another
block. Local variables are established each time a new
block is evaluated. Local variables appear to be global to any enclosed blocks. If a variable is non-local in a block, its value is the value most recently assigned by an enclosing block, if any, otherwise, it is the value of the variable in the global environment. This policy may coincide with the usual understanding of "dynamic scope".
The value of the block is the value of the last statement or the value of the argument to the function
return which may be used to exit explicitly from the block. The function
go may be used to transfer control to the statement of the block that is tagged with the argument to
go. To tag a statement, precede it by an atomic argument as another statement in the block. For example:
block ([x], x:1, loop, x: x+1, ..., go(loop), ...). The argument to
go must be the name of a tag appearing within the block. One cannot use
go to transfer to a tag in a block other than the one containing the
Blocks typically appear on the right side of a function definition but can be used in other places as well.
There are also some inexact matches for
?? block to see them.
(%o1) true (%i2)
dd('fun, vec, [point]...
merge(a) := block( lo...
f(x) := block(, if ...
n : 4;
W : matrix([0,-1,1,1]...