CTFE vs. traditional metaprogramming

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Oct 9 12:49:42 PDT 2009


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.


Andrei

div0 wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Andrei Alexandrescu wrote:
>> Thanks to all who answered! I wish there was such consensus in other
>> matters as well :o).
>>
>> Allow me to put forth an excerpt from TDPL without any particular
>> reason: http://erdani.com/tdpl/excerpt.pdf
>>
>>
>> Andrei
>>
> 
> "There are many random number generators out there, among
> which the fast and well-studied linear congruential generators."
>      ^
> You are missing an "are"
> 
> Personally I'd append something like:
> 
> "Therefore we wish to test the parameters to our generator" to the
> paragraph starting "But there is a rub."
> 
> Also:
> 
> The penultimate paragraph about interpretation process being slow seems
> rather redundant. It's just an implementation detail and dmd compiles
> huge libraries 1000x faster than c++ anyway.
> 
> - --
> My enormous talent is exceeded only by my outrageous laziness.
> http://www.ssTk.co.uk
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iD8DBQFKz4vrT9LetA9XoXwRAlrkAJ9QYiIv8XZ2H+lRuUSnyZV1HKDp6QCfdXig
> SVeeO0pY47V2vdWtbuZopmg=
> =ytCp
> -----END PGP SIGNATURE-----



More information about the Digitalmars-d mailing list