(j3.2006) Fw: a question on MERGE and expression evaluation
Thu Nov 18 19:12:22 EST 2010
Jim Xia wrote:
>I'm not convinced that all these answers are correct. The quoted text in
>previous replied are from clause 7 (on expression), and what they say is "you
>can omit expression evaluation if you're sure what the expression must be
No, that is not "what they say".
"It is not necessary for a processor to evaluate all of the operands
of an expression, *OR TO EVALUATE ENTIRELY EACH OPERAND*, if the value
of the expression can be determined otherwise."
Strangely enough, even though the precise words are there in the standard to
address your specific case you are ignoring them for some other reason.
> That's about operations evaluation like "expr1 .op. expr2" where you know the
> evaluation is true by evaluating expr1.
No, it is about
NOT EVALUATING ENTIRELY EACH OPERAND
if you don't have to to get the expression value.
> This is not what's happening here: "Merge(1/a, 0.0, a > 0)" is a function
> reference, right?
And it is AN OPERAND OF THE EXPRESSION. So it is PRECISELY what is happening
> And 12.5.3 seems to say 1.0/a should be evaluated at the function call.
And the quoted text says it DOES NOT HAVE TO EVALUATE ENTIRELY THAT FUNCTION
In fact, it does not have to evaluate the function reference at all - it can
evaluate any mathematically equivalent expression if we're getting picky.
> What do we say about this mandate?
Nothing. The processor didn't fully evaluate the function reference, and the
standard explicitly permitted it to do that.
................................Malcolm Cohen, Nihon NAG, Tokyo.
More information about the J3