[comp.lang.c] The Joy of Modular Macros

brnstnd@stealth.acf.nyu.edu (01/19/90)

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