Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!sdd.hp.com!hplabs!otter.hpl.hp.com!hpltoad!cdollin!kers From: kers@hplb.hpl.hp.com (Chris Dollin) Newsgroups: comp.lang.c Subject: Re: Re: macros and semicolons Message-ID: Date: 27 Jun 91 09:45:15 GMT References: <1991Jun24.213932.595@otago.ac.nz> <1991Jun24.144701.8479@world.std.com> <160662@pyramid.pyramid.com> Sender: news@hplb.hpl.hp.com (Usenet News Administrator) Organization: Hewlett-Packard Laboratories, Bristol, UK. Lines: 29 In-Reply-To: markhall@pyrps5.pyramid.com's message of 26 Jun 91 20:23:02 GMT Nntp-Posting-Host: cdollin.hpl.hp.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; Disclaimer: I am *not* advocating SWAP macros. But: #define SWAP(x, y) \ { int *splodge_x = &(x); int *splodge_y = &(y); int splodge_t = *splodge_x; \ *splodge_x = *splodge_y; *splodge_y = splodge_t; } does not suffer from the call-by-name problem (Algol 60 did not have call-by-reference, but Algol 68 does (in a manner of speaking). Hence Mark's criticism fails. However, the amount of effort required to write even a specialised swap macro should have suggested by now [anyone who hasn't, go read the FAQ] that swap macros are dead ducks. Dead, you hear me? D - E - D, DEAD. We now return you to your regular sniping about the NULL pointer. -- Regards, Chris ``GC's should take less than 0.1 second'' Dollin.