Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Always stops evaluating if..?
Message
De
15/08/2005 18:32:18
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
15/08/2005 17:59:28
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 7 SP1
Divers
Thread ID:
01041159
Message ID:
01041164
Vues:
26
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)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform