Ravi said:
Suppose we are given a statement:
f1(23,1) * f2(3) + f(4)
can you please tell what is the order of evaluation of these functions?
Only your implementation knows. The fact is that all is required is
that each of the functions be evaluated before its value is used.
People are sometimes confused by the precedence rules which they derive
from the grammar and imagine they imply something about the order of
evaluation of those functions. That is an error.
Consider
double foo(void)
{
double tmp1, tmp2, tmp3;
double f1(double,double);
double f2(double);
double f(double);
tmp1 = f1(23,1); /* note order: left to right */
tmp2 = f2(3);
tmp3 = f(4);
return tmp1*tmp2 + tmp3;
}
and
double foo(void)
{
double tmp1, tmp2, tmp3;
double f1(double,double);
double f2(double);
double f(double);
tmp3 = f(4); /* note order: right to left */
tmp2 = f2(3);
tmp1 = f1(23,1);
return tmp1*tmp2 + tmp3;
}
Notice that the result, apart from any unspecified side effects, does
not depend on the order of the function calls.