Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Always stops evaluating if..?
Message
From
15/08/2005 18:32:18
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 7 SP1
Miscellaneous
Thread ID:
01041159
Message ID:
01041164
Views:
27
This message has been marked as a message which has helped to the initial question of the thread.
>As far as I know, vfp always stops evaluating the right remainder of a logical expression if the left part evaluates to an logical value that cannot be changed anymore by the right remainder. For example, in the case of IF A OR B, the B is no longer evaluated if A evaluates to True. In a same vein, in the case of IF A=0 or BB(), the function BB is not visited if A=0.
>
>But now I am confronted with a case in a select-sql WHERE expression, where the part to the right of the OR is visited anyhow, notwithstanding the result of the left expression.
WHERE ( MOD(A,1000)#0 OR THERMO(A) )
>
>Does this sound familiar to anyone here?

I suppose that within a SQL command different rules apply, what with Rushmore Optimization. For example, in one particular case Visual FoxPro might decide that it is more efficient to evaluate the right-hand member first, because it is Rushmore-Optimizable. In any case, I wouldn't count on the right-hand expression not being evaluated within a SQL command (on the other hand, I would trust VFP to do shortcut boolean evaluation in most other cases).

If shortcut boolean evaluation is important in this case, you might move the entire combined expression to a UDF, or change it to an IIF().
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform