On Tue, Nov 26, 2002 at 09:16:54AM +0000, Matthew Byng-Maddick wrote: > On Mon, Nov 25, 2002 at 05:24:14PM -0800, Michael G Schwern wrote: > > There's no guarantee about the order of evaluation of arguments to a > > function in Perl (not sure if this generalizes to any list). Not sure why. > > I think C is the same way. Can't find where this is documented, I know its > > In C there are synchronisation points, and the postfix must happen before > the end of a synchronisation point, but the synch point for a function is
Yep, the Standard calls them "Sequence points". > (I believe) after the function arguments. I'm not sure about where the Yes. > prefix++ must happen. It's undefined. A sequence point happens at function entry, function return, semicolons, end of conditional expressions [if(f()+g()) <-- here] and with a few operators: &&, "", ?: and comma. I think that's all of them. So really not that many places - the compiler has quite a lot of latitude. Rule of thumb: Accessing a variable that's modified within a sequence point is a bad idea, and results in undefined behavior. Note of course that that could mean a side-effect way off in the depths of some call, not just in the immediate expression. Of course, this is C, and it's tightly defined. Still, anyone with a C background will have their hairs stand on end reading most of this thread :-) Paul -- Paul Makepeace ....................................... http://paulm.com/ "If I knew the answer to this question, then feeble screebles." -- http://paulm.com/toys/surrealism/
