function parameters
tanj at ucbvax.berkeley.edu
tanj at ucbvax.berkeley.edu
Wed Mar 12 08:34:27 AEST 1986
I just spent an hour trying to figure out why my working program
suddenly stopped working. Here's the culprit:
expand(*ptr++,*ptr++,*ptr++,ptr++,ptr++,ptr++);
(I'm working on a graphics project, which involves mapping surface
textures to the surface of a torus {bagel}. Expand takes a point
and its norm and expands it to 16 more points by symmetry.)
After careful searching of K&R I found the reason;
The order of evaluation of arguments is undefined by the
language; take note that the various compilers differ.
[p. 186]
The compiler I am using evaluates right to left. If I were to number
the above arguments 1-6, when expand gets them they are 6-1. I find
this contrary to my intuition. Can anyone out there give me a good
reason as to why this is left up to compiler implementation? And
if so is it generally true that evaluation of parameters is r-l?
Sincerely,
Michael Berman
(tanj at ucscc.BITNET)
More information about the Comp.unix.wizards
mailing list