Article on code features in C++ by Scott Meyers + sidebar on D implementation by Bartosz Milewski

Bill Baxter wbaxter at gmail.com
Tue Sep 23 17:40:54 PDT 2008


On Wed, Sep 24, 2008 at 6:59 AM, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> http://www.artima.com/cppsource/codefeaturesP.html
>
> Andrei
>

Cool beans.  A nice intro to the power of D template metaprogramming!
That was nice of Scott to put it right alongside his C++ code.

Bartoz, regarding this:

>> Incidentally, the same string can be generated and printed at run time using this line of code:
>>
>> writeln (declareAllFeatures (["Tested", "Portable"]));

you might want to also mention that you can debug such strings at
*compile time* too using something like:

pragma(msg, "FEATURE CODE:\n" ~ declareAllFeatures (["Tested", "Portable"]));

Usually that's much more useful than trying to print them at runtime.

Also this has a typo:

>> the compiler run out of memory at nine features

*runs* out of memory or *ran* out of memory.

About this:
>> Compilation times for the D implementation are negligible for up to seven features. The compilation of eight features took two minutes, and the compiler run out of memory at nine features.

You might want to mention that the reason is that the compile-time
interpreter simply hasn't been fitted with a garbage collector yet.
Actually there are hooks in DMD for using GC internally -- I think the
LLVMDC folks experimented with turning it on.  It did make that CTFE
problem go away, but there was another problem elsewhere that cropped
up.  LLVMDC folks correct me if I'm wrong on that.

--bb


More information about the Digitalmars-d-announce mailing list