Hello Michel,

On 2009-10-09 15:49:42 -0400, Andrei Alexandrescu
<seewebsiteforem...@erdani.org> said:

Thanks!

I plan to add more text at the end of the chapter that discusses the
opportunities of CTFE. Walter revealed to me that CTFE, particularly
now after it's been improved by leaps and bounds by Don and by Walter
himself, could obviate a lot of the traditional metaprogramming
techniques developed for C++.

One question that bugs me is, where do you draw the line? Say there's
a metaprogramming problem at hand. How to decide on solving it with
CTFE vs. solving it with templates? It would be great to have a
simple guideline that puts in contrast the pluses and minuses of the
two approaches.

It is quite possible that templates get relegated to parameterized
functions and types, whereas all heavy lifting in metaprogramming
should be carried with CTFE.

My idea on templates is that they're good when you have type
parameters, or to create types based on constant parameters.

- - -

But an interesting thing I realized in the last few months is this:
all you can do with a template you can also do at runtime provided
sufficient runtime reflection capabilities. Even creating types!
Details follow.


I'd like to forward the thought that runtime reflection and type creation is NOT a replacement for the same at compile time just as the compile time version is not a replacement for the run time version.

Just to pick two differences: errors are forced to runtime and runtime types can't be inlined.


Reply via email to