[ prog / sol / mona ]

prog


Post macros.

35 2020-08-17 14:28

>>34
The thread is about "dirty little macros", not "neat elegant macros made by lisp wizards". There are neat things...
C preprocessor can handle variadic arguments by switching on number of arguments:
https://stackoverflow.com/a/26408195
This can be used with _Generic to create type-generic, variadic macros. The C preprocessor arglist is also a tuple which can be manipulated with purely lexical macros such as above "unwrap",
using tokens, VA_ARGS and clever preprocessor hacks to achieve stuff that would normally be out of C reach.
Boost preprocessor library explores the more arcane ideas closer to functional programming, but utility macros are neat without introducing any layers of parsing themselves.
If you use LISP you probably recognize the idea of composition-type(##) token manipulation as primitive form of reader macros:
these combined tokens can be parsed as macro names which themself could expand to another composition,etc.

40


VIP:

do not edit these