An user function of Asir is defined in the following form.
def name(parameter, parameter,...,parameter) {
statement
statement
...
statement
}
As you can see, the statement is a fundamental element of the function. Therefore, in order to write a program, you have to learn what the statement is. The simplest statement is the simple statement. One example is an expression with a terminator (`;' or `$'.)
S = sum(N);
A `return statement' and `break statement' are also
primitives to construct `statements.'
As you can see the syntactic definition of `if statement' and
`for statement', each of their bodies consists of a single
`statement.' Usually, you need several statements in such a body.
To solve this contradictory requirement, you may use the `compound
statement.' A `compound statement' is a sequence of `statement's
enclosed by a left brace `{' and a right brace `}'.
Thus, you can use multiple statement as if it were a single statement.
if ( I == 0 ) {
J = 1;
K = 2;
L = 3;
}
No terminator symbol is necessary after `}',
because `{' statement sequence `}' already forms a statement,
and it satisfies the syntactical requirement of the
`if statement.'
Go to the first, previous, next, last section, table of contents.