Rendered at 13:51:50 GMT+0000 (Coordinated Universal Time) with Cloudflare Workers.
teo_zero 7 hours ago [-]
There are a couple of constructs that you end up re-creating as soon as you need non-trivial preprocessing.
One of those is the two-stage CAT, another one is the NARG the article talks about.
__COUNTER__ is going to be added to C29, the next version of the standard, maybe there's hope for __VA_COUNT__ and __CAT__ too!
0c3ca83 3 hours ago [-]
Doing non-trivial preprocessing is a mistake. You get slow compilation, hard to debug code, opaque and fragile code, and incredible complexity. If you want metaprogramming, you're better off with C++ it you need C header compatibility, or zig if you don't.
Otherwise, it's probably a good idea to pretend that the only preprocessing directive is #include. With constexpr, even #define is obsolescent.
teo_zero 32 minutes ago [-]
Doing non-trivial anything you slow down compilation, make debugging harder and increase fragility and complexity. Sometimes that's a mistake, sometimes not.
Getting rid of something because someone sometimes abuses it, is short-sighted.
HexDecOctBin 5 hours ago [-]
Has anyone tried to extend the C Preprocessor to be a fully turing complete language (perhaps something like Snobol) to allow for Terra like meta-programming?
(I am not talking about metalang99 or Cello like stuff, which exploits the Turing tarpit of the currently specified preprocessor but rather tasteful additions to the preprocessor itself).
camel-cdr 2 hours ago [-]
The C preprocessor is practically turing complete, in the same sense that C it self or your computer is practially turing complete, but not strictly.
0c3ca83 3 hours ago [-]
C++ started as a preprocessor.
cowlevel 1 hours ago [-]
but not the C preprocessor, but a completely different preprocessor.
But that repo says it's effortful for the preprocessor and you can see in the code it's a recursion limited but what's in the file. If you had, maybe, a few thousand register definitions in an embedded system, that won't do it.
david2ndaccount 23 hours ago [-]
The article shows how to implement map, but it should be a builtin
One of those is the two-stage CAT, another one is the NARG the article talks about.
__COUNTER__ is going to be added to C29, the next version of the standard, maybe there's hope for __VA_COUNT__ and __CAT__ too!
Otherwise, it's probably a good idea to pretend that the only preprocessing directive is #include. With constexpr, even #define is obsolescent.
Getting rid of something because someone sometimes abuses it, is short-sighted.
(I am not talking about metalang99 or Cello like stuff, which exploits the Turing tarpit of the currently specified preprocessor but rather tasteful additions to the preprocessor itself).