What I love are macros that take parameters that are the names of other macros to call, and parameters that are fragments of code without balanced brackets to insert.

The term of art for that and the X pattern kind of approach is "macrology".

An infamous example is Microsoft's original C preprocessor macros for generating COM components for C code.

MFC infamously used a similar approach for its COM/OLE bindings to C++ too. You could include the same interface definition .h files in either C or C++ code with the proper meta-macros defined to declare the same interfaces in either C or C++ code (which was kind of the whole point of COM).

That was long before the (in contrast) much more elegant ATL (ActiveX Template Library) implemented with C++ templates.

Microsoft isn't the only offender -- Sun did it to!

Check out the "arctochain.c" code in the original NeWS server by Vaughan Pratt and James Gosling for a great example of macros that take the names of other macros and code fragments containing gotos, to make a state machine with a twisty maze of hopping gotos, plus some manual exception handling gotology like "goto this_curve_is_trash;" and "goto straight;" thrown in for fun:

https://donhopkins.com/home/NeWS/SUN/src/server/graphics/arc...

/*-
Convert a conic arc to a curve

arctochain.c, Tue Jun 11 14:23:17 1985

"Elegance and truth are inversely related." -- Becker's Razor

Vaughan Pratt
Sun Microsystems

This code is a version of the conix package that has been
heavily massaged by James Gosling.
*/

More NeWS macrology:

https://news.ycombinator.com/item?id=15680904

>[...] Two pieces of work were done at SUN which provide other key components of the solution to the imaging problems. One is Vaughan Pratt's Conix [53], a package for quickly manipulating curve bounded regions, and the other is Craig Taylor's Pixscene [63], a package for performing graphics operations in overlapped layers of bitmaps. [...]

>[...] Pixscene is based on a shape algebra package. The ability, provided by Conix, to do algebra very rapidly on curves should make non-rectangular windows perform well. [...]

>[53] Pratt, V., Techniques for Conic Splines, Computer Graphics 19(3), pp.151159 (1985).

>[63] Taylor, C. and Pratt, V., A Technique for Representing Layered Images. SUN Microsystems Inc., 2550 Garcia Avenue, Mountain View, CA94043.

Techniques for Conic Splines:

https://dl.acm.org/doi/pdf/10.1145/325334.325225

>The main loop of the NeWS PostScript interpreter itself is the realization of Duff's dire warning "Actually, I have another revolting way to use switches to implement interrupt driven state machines but it's too horrid to go into."

https://news.ycombinator.com/item?id=4360306

https://www.lysator.liu.se/c/duffs-device.html

https://donhopkins.com/home/code/NeWS/SUN/src/server/nucleus...

The blocking PostScript parser also has some charming macrology, by the same guy who brought you Java, written in the morning of New Years Eve 1984:

https://donhopkins.com/home/code/NeWS/SUN/src/server/nucleus...

#define case4(tag) case tag: case tag+1: case tag+2: case tag+3
#define case16(tag) case4(tag):case4(tag+4):case4(tag+8):case4(tag+12)
#define case32(tag) case16(tag):case16(tag+16)