IF statement

Language reference ›› Statements ››
Parent Previous Next

if-statement = IF boolean-expression THEN [ block ] [ ELSE block ] .

An IF statement is optimized for bit Boolean use, but in non-strict mode PMP also accepts a non-boolean expression: any value that is not zero is evaluated as TRUE (1).


Optimizations:


If <boolean-expression> evaluates to a constant value equal to 0 (FALSE), no code is generated for the <boolean-expression> evaluation and for the next block and the ELSE block is generated.

If <boolean-expression> evaluates to a constant value not equal to 0 (TRUE), no code is generated for the <boolean-expression> evaluation and the next block is generated and no code is generated for the ELSE block.


These two cases permit the use of constants for generating code that is always checked, in replacement to $IFDEF constructs that don't.