RAD Studio (Common)
ContentsIndex
PreviousUpNext
Boolean short-circuit evaluation (Delphi compiler directive)
Type  
Switch  
Syntax  
{$B+} or {$B-} {$BOOLEVAL ON} or {$BOOLEVAL OFF}  
Default  
{$B-} {$BOOLEVAL OFF}  
Scope  
Local  

Remarks 

The $B directive switches between the two different models of Delphi code generation for the and and or Boolean operators. 

In the {$B+} state, the compiler generates code for complete Boolean expression evaluation. This means that every operand of a Boolean expression built from the and and or operators is guaranteed to be evaluated, even when the result of the entire expression is already known. 

In the {$B-} state, the compiler generates code for short-circuit Boolean expression evaluation, which means that evaluation stops as soon as the result of the entire expression becomes evident in left to right order of evaluation.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!