
A6.7 Statements 137
Labels are the targets of goto statements (see §A6.7.5); labels are local to a function
and have separate name spaces (which means that variables and labels may have the
same name).
A6.7.1 Assignment statements
An assignment statement assigns the result of an expression to a variable (or an element
in a variable). If a function has multiple returns, the result can be assigned to multiple
destinations, by listing the destinations within curly braces, separated by a comma (see
the example in §A6.6.3).
If an assignment is made at the external level (outside any function), then the vari-
able is automatically created if it does not exist yet. Inside a function, a left-hand
variable must exist, either externally, or after creation with the local statement.
The let statement is similar to declare,see§A6.6.2, except that there is no type
component, and only = for the assignment.
The clear statement is followed by a comma-separated list of identifiers. This
is the same as issuing a let identifier tt = 0; statement for each variable (so inside
a function, the variable must be declared with local first). The clearg command
only works on global variables, so, even if a local with the same name exists inside a
function, the global is set to 0, and the local left untouched.
If an expression is executed without assignment, the result is printed.
A6.7.2 Selection statements
selection-statement:
if expression ; statement-list
opt
endif ;
if expression ; statement-list
opt
elseif-statement
opt
else-statement
opt
endif ;
elseif-statement:
elseif expression ; statement-list
opt
else-statement:
else ; statement-list
opt
The conditional expression in an if statement is evaluated, and if it is nonzero
(TRUE (for a matrix: no element is zero)
∗
, the statement is executed. If the expression
is zero (FALSE)theif part is not executed. The conditional expression may not be a
declaration statement.
A6.7.3 Iteration statements
iteration-statement:
do while expression ; statement-list endo;
do until expression ; statement-list endo;
for identifier ( init-expr, test-expr, increment-expr); statement-list endfor;
Kommentare zu diesen Handbüchern