Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!uhccux!munnari.oz.au!mimir!hugin!augean!sirius!nt!levels!ccdn From: CCDN@levels.sait.edu.au (DAVID NEWALL) Newsgroups: comp.lang.c Subject: Re: Obfuscated SWAP: not portable! Message-ID: <1400@levels.sait.edu.au> Date: 4 Sep 89 10:53:41 GMT References: <784@skye.ed.ac.uk> <1267@levels.sait.edu.au> <149@cpsolv.UUCP> Organization: Sth Australian Inst of Technology Lines: 19 In article <149@cpsolv.UUCP>, rhg@cpsolv.UUCP (Richard H. Gumpertz) writes: > The exchange of x and y that has been under discussion: > x ^= y ^= x ^= y > is non-portable because it depends on right-to-left evaluation which is NOT > specified in the C standard. I think it is specified. (Perhaps it depends on whose standard you follow?) K&R I, page 19: "The line nl = nw = nc = 0; sets all three variables to zero. This is not a special case, but a consequence of the fact that an assignment has a value and assignments associate right to left." David Newall Phone: +61 8 343 3160 Unix Systems Programmer Fax: +61 8 349 6939 Academic Computing Service E-mail: ccdn@levels.sait.oz.au SA Institute of Technology Post: The Levels, South Australia, 5095