Procedural
void Function Calls
Declare a function that no return value.
WIP
return Statement
Returns a value to the caller from a function or exec block.
Syntax:
return expression ;
- expression : An optional value need for returned to the caller.
repeat Statement
Executes procedural_stmt repeatedly by specified the number of iteration. Syntax:
repeat (index_identifier : expression) procedural_stmt
- index_identifier : An optional index-variable identifier can be specified that ranges from
0to*iteration* - 1. - expression : Specify iteration by a non-negative integer (e.g.,
intorbit). - procedural_stmt : Iterated by the number of iteration. Not executed if iteration is
0.
repeat-while Statement
Executes procedural_stmt repeatedly as long as the expression is true. Syntax:
repeat procedural_stmt while (expression);
- procedural_stmt : Iterated so long as the expression is true.
- expression : Evaluates true or false everytime after procedural_stmt.
while Statement
Executes procedural_stmt repeatedly as long as the expression is true. Syntax:
while (expression) procedural_stmt
- procedural_stmt : Iterated so long as the expression is true.
- expression : Evaluates true or false everytime before procedural_stmt.
foreach Statement
Executes procedural_stmt for each element of the expression. Syntax:
foreach (iterator_identifier : expression [index_identifier]) procedural_stmt
- iterator_identifier : An optional iterator-variable identifier with collection element type, an is an lias to current element.
- index_identifier : An optional index-variable identifier can be specified that ranges from
0tosize() - 1when expression isarray-type orlist-type; or can be specified of all keys when expression ismap-type. - expression : A collection type (e.g.,
array,list,map, orset). - procedural_stmt : Iterated by the number of
size()of the expression.
Warning
- For
set-type, index_identifier should NOT be specified. - At least one of iterator_identifier or index_identifier should be specified.
- Both iterator_identifier and index_identifier should NOT be changed inside procedural_stmt.
Note
- A colon (
:) must be append after iterator_identifier if its specified. - A pair of square brackets (
[]) must be used to contain index_identifier if its specified. - The order of keys are undetermined when expression is
map-type.
Usage: iterating over a sequence without declare collection
When needing to iterate over a sequence of elements, the sequence can defined inside foreach directly.
Even defined a collection inside foreach also acceptable.
if-else Statement
Executes procedural_stmt_for_true when expression is true. Syntax:
if (expression) procedural_stmt_for_true else procedural_stmt_for_false
- expression : Evaluates true or false.
- procedural_stmt_for_true : Executed when the expression is true.
- procedural_stmt_for_false : An optional procedural will be executed when the expression is false.
Bug
When if statement is used in constraint block to constraint random-variable, the else statement SHOULD be used to prevent incorrect possible values.
- Even an empty procedural_stmt_for_false can prevents incorrect possible values.
match Statement
Executes procedural_stmt when corresponding range is match to the expression. Syntax:
match (expression) {
[range] : procedural_stmt
[range] : procedural_stmt
...
default : procedural_stmt
}
- expression : The item to be evaluated.
- range : An open range list is compared to expression.
- procedural_stmt : Executed when expression matches any one in corresponding range.
- default : An optional procedural will be executed when not any range was matched.
Warning
- Only one of ranges should be matched.
- The
defaultmust be exist and executed if no any range was matched.
break Statement
Continues execution after enclosing innermost loop construct. Syntax:
break;
Warning
The break statement may only appear within loop statements (repeat, repeat-while, while, or foreach).
continue Statement
Continues next loop iteration. Syntax:
continue;
Warning
The continue statement may only appear within loop statements (repeat, repeat-while, while, or foreach).
randomize Statement
Randomize the specified data attributes or variables.
Syntax:
randomize variable, .., variable with constraints
- variable: A set variables of plain-data type to randomized together.
- constraints: Optional constraint rules.
exec Block
Created: 2023-10-24