Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!plx!dlb!megatest!djones From: djones@megatest.UUCP (Dave Jones) Newsgroups: comp.lang.c Subject: Re: comma operator Message-ID: <227@goofy.megatest.UUCP> Date: 23 Jan 88 00:48:21 GMT References: <2382@ihuxv.ATT.COM> Organization: Megatest Corporation, San Jose, Ca Lines: 31 in article <2382@ihuxv.ATT.COM>, rck@ihuxv.ATT.COM (R. C. Kukuk) says: > > In article <7137@brl-smoke.ARPA>, gwyn@brl-smoke.ARPA (Doug Gwyn ) writes: >> In article <3887@sigi.Colorado.EDU> swarbric@tramp.Colorado.EDU (SWARBRICK FRANCIS JOHN) writes: >> >#define swap(a,b) ((a) = ((b) = ((a) = (a) ^ (b)) ^ (b)) ^ (a)) >> >He says it will work for anything (int, char *, etc.). >> > This oldie fails when a == b. Why? Think about it. > > > Re: Another discussion in this news group -- > > Note that I said "a == b"; not "a = b". :-) > > Ron Kukuk > AT&T Bell Labs I think some clarification is in order: What Ron means is that swap(X,X) will not work. Sets X to 0 always. { int a; int b; a = 5; b = 5; swap(a,b); } works just fine. Dave Jones Megatest Corp.