delphi - break condition to OR and AND operators in an IF Statement -


the if statement , other boolean comparison smart enought stop @ first false value when evaluating a , b , c , d , @ first true value when evaluating a or b or c or d.

what name of behavior?
compiler optimization? if so, there way disable compiler directive?

this called 'boolean short-circuit evaluation', form of 'lazy evaluation'.

you can tell compiler either use or not use feature using compiler directives:

complete evaluation     lazy evaluation {$b+}                   {$b-} {$booleval on}          {$booleval off}  

but notice isn't only optimisation, since feature allows write code like

if (length(myarr) > 0) , (myarr[0] = my_val) 

which work if myarr[0] doesn't exist. rather common, actually.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -