Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
AND and OR evaluations in conditional statements
Message
De
16/04/1999 00:43:08
 
 
À
15/04/1999 07:04:00
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00206066
Message ID:
00208862
Vues:
27
>So they were giving you a way to bypass the 'natural' way of doing things if it was useful to you. You call this "optimization"???

This "natural" can go into a very long discussion! :) Only that I don't know if it would be useful to anyone, so... I won't start it. :)

>You know, when I started programming there was *only* sequential reading available. Once we got direct access, we did *not* all go around claiming that our programming was now "optimized". The manufacturer did *not* go around claiming that they had "optimized" their system(s).

ROFL! You are right here. Well, this is the progress of marketing in the software "industry". :)

>When you have misplaced something and decide on a list of places to look for it, do you go to *all* those places even though you found the thing on the third of 10 places??? Of course not! You didn't "optimize" your search, you just smartly stopped once there was no value in continuing.

Your analogy is nice, but it doesn't apply 100% here. The complete evaluation is very good when the logical expressions involve functions with side effects. Of course, one could reply that if the functions have side effects, then they can be called before, the return values stored into variables and these variables used in the actual logical expression.

Still, there are cases when this is not an option. For ex: I would like to be able to:

REPLACE AField WITH a() OR b() FOR SomeCondition

where b() has some very useful side effects.

But I can't do it in VFP. I don't want to go into a long discussion about the fact that functions with side effects are good or bad, etc. Sometimes, in real life, these functions exist and I would like to use them as above.

IMHO, complete/short evaluations have their pros and cons. I like that VFP knows how to do short evaluations. Still, I have some pros for complete eval also. :)

Now, if you go more deep into the rules that are applied by compilers to be able to do short evals of logical expressions, you will see that this "domain" is not at all as simple as the specific case in discussion. When these rules become really complicate, it's difficult not to call them optimizations. There are different levels of such optimizations (or, different levels of complexity). Not all compilers know how to apply all the important rules. So, I would call them optimizations because they really do better something that I was too lazy to optimize my self! :)

Vlad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform