General information
Category:
Coding, syntax & commands
>Can you show me an example of AND getting evaluated before OR is when the OR is to the left of the AND?
It's not a matter of time sequence of evaluations for operators. The operator precedence gives only the operand grouping. The order (in time) to evaluate each operation/operands depends on the compiler and it doesn't matter as long as the result is correct. (It doesn't matter for logical operation if there are no functions with side effects involved. In many cases, it matters for arithmetic operations because of the unavoidable roundings. Some programs will change the order in arithmetic operation evaluation just to get the best possible precision.)
>If I ask ? 5 + 2 * 7 the reply is 19 because the * is done before the + due to precedence. But if I ask ? a OR b AND c and a is true the AND never gets evaluated, if I put the and first then the and gets done first. It certainly appears that the expression is being evaled from left to right regardless of teh and/or distribution.
While f() + g() * h() may give you the following operand evaluation order in time: f, g, h. (Which is what VFP does!) This doesn't mean + is evaluated before *.
Vlad
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only