Home > Language Reference > Operators

Strict Operator

Locally disable all optimizations for expression evaluation.

Syntax

Result = Strict( Expr )

ParameterDescription
ResultResult of the operation.
ExprExpression to be fully evaluated.

Remarks

The Strict keyword is not strictly speaking an operator, but rather a pseudo-function. However, it is listed in this section because it affects how operators are evaluated.

Usually, the compiler is free to perform various optimizations when it generates code for an expression. Notably, it can drop parts of an expression whose values are not required to compute the final result, especially with boolean operators. This can happen either at compile-time or at runtime, depending on the context, as shown below:

x = True Or MyFunc()        ' The whole expression is dropped and replaced by True at compile-time.
x = MyFunc1() And MyFunc2() ' MyFunc1 is always called; when it returns False, the call to MyFunc2 is skipped as it is useless.

The Strict pseudo-function locally disable those optimizations. The expression it encloses is always fully evaluated, from left to right, exactly as it is written. For example:

x = Strict( MyFunc1() And MyFunc2() ) ' Both functions are always called.

This feature may prove useful if parts of an expression are function calls that have side-effects, such as altering a global variable, or opening a message box. However, it is always better to avoid this kind of programming. Writing functions with side-effects lead to bug that may be really difficult to track down. Moreover, locally disabling optimizations impacts performances.

System requirements

SystemMinimal versionRemarks
Palm OSPalm OS 3.0-
Windows CEWindows CE 3.0-