Skip to content

Comment on CPIP – A C/C++ preprocessor implemented in Pythonparent

Comments

macros allow you to do a degree of metaprogramming

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++".)

I'll admit, I didn't write the comment with the expectation that it would be attacked on believability, but I'll try to give a satisfactory response:

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)

This is all wrong actually. Modern C++ lets you do AST type stuff without this macro nonsense.

Really? That's awesome! How??

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.