Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
EVL and NVL
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00905138
Message ID:
00906522
Views:
17
Sorin,

>I just don't see how the optimization would be able to reach a deterministic result as long as the intermediate value is NULL. Regardless of the following operator, the next operand in the expression must be evaluated. In your examples above there is no optimization; the entire expression is evaluated, as it would be the case with any
>NULL AND anything or
>NULL OR anything

When the NULL is the left operand the right operand must be evaluated. When the null is on the right it may or may not be accessed depending on the left operand and the operator. Relook at these highlighted pieces of the truth table:
   X   |   Y    |  X and Y   |  X OR Y
-------+--------+------------+----------
.T.    | .NULL. |            | .T.     X 
.F.    | .NULL. | .F.    X   |
In both these two cases only the left operand is accessed.

Here is further proof.
x = .null.
y = .null.
z = .t.
w = .null.

lcRead = ""
? IsEval( "X" ) or IsEval( "Y" ) or IsEval( "Z" ) or IsEval( "W" ), lcRead

lcRead = ""
z = .f.
? IsEval( "X" ) and IsEval( "Y" ) and IsEval( "Z" ) and IsEval( "W" ), lcRead

function IsEval( lcOperand )
lcRead = lcRead + lcOperand + " "
return eval( lcOperand )
The result is:
.T. X Y Z
.F. X Y Z
In both cases W is not evaluated. In the first case X Y and Z must be evaluated and since Z is true and the next operator is OR the access of W is optimized away. Likewise for the AND case since Z is false the access of W is eliminated.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform