CPIP – A C/C++ preprocessor implemented in Python
cpip.sourceforge.net
cpip.sourceforge.net
Now, that doesn't change the fact that this project is cool and could lead to interesting developments but are preprocessor advancements a good thing in general for C++ or is it moving backwards?
I think this comment would be more believable if you provided some examples. Since you didn't, let me provide one and then hopefully you (or someone else) can provide more.
http://journal.stuffwithstuff.com/2012/01/24/higher-order-ma...
I would provide a summary, but I think you can get a hint just from the URL. (Actually, the URL is misleading. The title of the blog post is "Higher Order Macros in C++".)
The definition of metaprogramming is "the writing of computer programs that with the ability to treat programs as their data", which #defines can certainly do, and which decorators in a slightly different sense also do. I hate to just drop Wikipedia links, but it says it far better than I could, and contains an example of using C style macros to do templated metaprogramming. (http://en.wikipedia.org/wiki/Metaprogramming)
Wouldn't this be the main reason C is predominant, combined with historical reasons a la 'predecessor used C as well'? I find it hard to believe one wouldn't be able C++ which is as efficient as C. Afaik the preprocessor features are exactly the same. Also I've seen the virual function overhead card being played too much and it doesn't make too much sense: one can benefit from goodies like templates/lambdas/STL without using virtual inheritance. And all those goodies mostly appear when writing the code, i.e. make for faster cleaner development: after the compiler went over it they are all optimized away and turned into what looks a whole lot like assembly generated from plain C.
However, one very important bit, where we (sadly) are not really moving away from: The include system. This is still handled all by the preprocessor.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n404...
The other one is the clang one
- includes (until modules become available)
- conditional compilation
Macros are better replaced with inline, constant expressions, templates with the added benefit of type safety and debugger support.
'Modern' C++ does not depend so stongly on a preprocessor however C does and most big C projects use all features of the C preprocessor, however opaque. This is why I chose to illustrate CPIP with preprocessing a single file from the linux kernel: http://cpip.sourceforge.net/copy_to_html/cpu/index_cpu.c_942...