Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!overload!dillon From: dillon@overload.Berkeley.CA.US (Matthew Dillon) Newsgroups: comp.sys.amiga.programmer Subject: Re: Side Effects == Rattlesnakes -- watch out for them Re: Compiler code (was a flame fest) (now a lesser flame fest) Message-ID: Date: 5 May 91 21:48:31 GMT References: <24503@well.sf.ca.us> <1991May4.061257.14959@zorch.SF-Bay.ORG> <1991May4.161920.23798@NCoast.ORG> Organization: Not an Organization Lines: 34 In article <1991May4.161920.23798@NCoast.ORG> davewt@NCoast.ORG (David Wright) writes: >In article <1991May4.061257.14959@zorch.SF-Bay.ORG> xanthian@zorch.SF-Bay.ORG (Kent Paul Dolan) writes: >>> jsmoller@jsmami.UUCP (Jesper Steen Moller) writes: >>>> Oh, by the way: func(a++) Is "a" increased before or after the >>>> function call. I think I once read in K&R that it was undefined, but >>>> I might be mistaken. >>Which still leaves the wide open "gotcha" that if func() modifies "a" >>by a side effect during execution, all bets are off as to whether the >>pre-call or the post-call value is what gets incremented and stored >>back in "a". > Really? How can it do this unless you are passing a *pointer*? >and if "a" is a pointer, and is passed to func(), there is no way for func() Well, 'a' could be a global, or part of a structure that's accessible through other means. But I believe expressions in a function call are sequenced so all side effects will have been done by the time the function is called. You don't know which ORDER the expressions in a function call are calculated though. >> >>Best rule for C side effects -- don't. >> >>Kent, the man from xanth. >> -Matt -- Matthew Dillon dillon@Overload.Berkeley.CA.US 891 Regal Rd. uunet.uu.net!overload!dillon Berkeley, Ca. 94708 USA