Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!njin!uupsi!cmcl2!stealth.acf.nyu.edu!brnstnd From: brnstnd@stealth.acf.nyu.edu Newsgroups: comp.lang.c Subject: The Joy of Modular Macros Message-ID: <26261@stealth.acf.nyu.edu> Date: 18 Jan 90 21:59:53 GMT References: <21068@stealth.acf.nyu.edu> <1990Jan18.002842.441@aqdata.uucp> Reply-To: brnstnd@stealth.acf.nyu.edu (Dan Bernstein) Distribution: usa Organization: IR Lines: 18 X-Original-Subject: Re: Is this swap() macro correct? In article <1990Jan18.002842.441@aqdata.uucp> sullivan@aqdata.uucp (Michael T. Sullivan) writes: > From article <21068@stealth.acf.nyu.edu>, by brnstnd@stealth.acf.nyu.edu: > > #define block do { > > #define endblock } while(0) [ and then I go on to use block and endblock in the swap macro ] > Why are "block" and "endblock" even bothered with here. Why not just > put the "do {" and "} while (0)" in the definition of swap? Could > somebody please enlighten me. It's a secret plot to render your machine useless by wasting microseconds of cpp time. :-) Seriously, I use block and endblock because that's how I think about the structure. Modularization makes programs easier to read and understand; here it insulates swap from changes in the expression of block/endblock. Is that sufficiently enlightening? ---Dan