Is metaprogramming useful?

Frank Benoit (keinfarbton) benoit at tionex.removethispart.de
Mon Nov 27 05:28:15 PST 2006


In generic programming we can do wonderful things like container classes
and template functions.

Using more advanced feature will result in metaprogramming, like the
compile time regex.

I wonder if compile time regex is really a thing of practical use.

If I a lot of compile time regex pattern, it is very nice to have
compiler error for invalid patterns.

But disadvantages are:
- compile time is increasing fast
- code size is increasing with every new pattern (is it?).

With a parser like Spirit in C++ it would be the same. In the Spirit
FAQ, a 78 rule parser was reported with 2 hours compile time.

Well, D might be faster, but it shows that the compile time can increase
very fast.

In both cases an external regex or parser generator would make more sense.

Now my questions:
1.) Is metaprogramming really useful or only kind of hype?
2.) Are there examples where a metaprogramming solution is the best way
to solve it?



More information about the Digitalmars-d mailing list