Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!olivea!uunet!nss1!mrm From: mrm@nss1.com (Michael R. Miller) Newsgroups: comp.lang.c Subject: Re: macros and semicolons Message-ID: <1991Jun28.134517.5972@nss1.com> Date: 28 Jun 91 13:45:17 GMT References: <1991Jun24.213932.595@otago.ac.nz> <160662@pyramid.pyramid.com> <6531@goanna.cs.rmit.oz.au> Organization: XZaphod of Rockville, MD Lines: 15 Send-Reply-To: uunet!xzaphod!michael In article <160662@pyramid.pyramid.com>, markhall@pyrps5.pyramid.com (Mark Hall) writes: > ... > NO macro will work for a swap. You suffer from the call-by-name rule ^^^^^^^^ > which undid ALGOL in this case. Consider the expansion of SWAP(i,a[i]): > > int c; c = i; i = a[i]; a[i] = c; How about: #define swap(x, y) (x ^= y ^= x ^= y) Why won't this do the swap as requested? I've done this before. The only presumption, which was carried forward from the above text, is the types are compatible (not only size but type).