Next: , Previous: , Up: Complex statements   [Contents][Index]


4.7.4 Conditional execution

Like most programming languages, coNCePTuaL supports conditional code execution:

<if_stmt> ::= IF <rel_expr>
THEN <simple_stmt>
[ OTHERWISE <simple_stmt>]

The semantics of an <if_stmt> are that if <rel_expr> (see Relational expressions) is TRUE then the first <simple_stmt> is executed. If <rel_expr> is FALSE then the second <simple_stmt> is executed. One restriction is that <rel_expr> must return the same truth value to every task. Consequently, functions that involve task-specific random numbers (see Random-number functions) are forbidden within <rel_expr>.

The following is an example of an <if_stmt>:

IF this>that THEN TASK 0 SENDS A 3 KILOBYTE MESSAGE TO TASK this
OTHERWISE TASK num_tasks-1 SENDS A 4 KILOBYTE MESSAGE TO TASK that
Scott Pakin, pakin@lanl.gov