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

Bill Baxter wbaxter at gmail.com
Wed Sep 24 16:26:42 PDT 2008


On Thu, Sep 25, 2008 at 7:31 AM, Hoenir <mrmocool at gmx.de> wrote:
> Bill Baxter schrieb:
>>
>> 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"]));
>>
> Doesn't work for me. It expects a string literal.

Then your implementation of declareAllFeatures is maybe not CTFE-able.

This works (D1.035):

string declareAllFeatures(string[] features)
{
    string ret;
    foreach(f; features) {
        ret ~= "Feature: " ~ f ~ "\n";
    }
    return ret;
}
pragma(msg, "FEATURE CODE:\n" ~ declareAllFeatures (["Tested", "Portable"]));
void main() {}


--bb


More information about the Digitalmars-d-announce mailing list