Version Identifiers for Platforms / Architectures not supported byDMD

Walter Bright newshound2 at digitalmars.com
Wed Nov 9 15:58:17 PST 2011


On 11/9/2011 6:46 AM, Daniel Murphy wrote:
> But, as it is a breaking change (very slightly), and a
> special case, I doubt this will ever happen unless Walter loves the idea.
> Walter?

Sorry, I don't love the idea. I dislike it for its inconsistency with the rest 
of the language. The trend in programming languages and operating systems has, 
for a long time, been towards case sensitivity.

BTW, the correct way to write version sensitive code is:

version (linux)
{
    ...
}
else version (OSX)
{
    ...
}
else
    static assert(0, "unsupported OS version");


Otherwise, it's miserable to find and tweak all the version sensitive code in 
your codebase. Here's a WRONG WRONG WRONG way:

version (linux)
{
     ...
}
else /* Windows */
{
     ...
}

Looks stupid, but I tend to often see stuff like this in C, C++ and D source 
code. Even in my own. This is also why there's no ! for versions:

version (!linux)
{
     ...
}

Aaaaggghhhh. I'm pretty fed up with seeing that crap in C code. And if you see 
any of it in dmd or phobos sources, please file a bugzilla report! Show no mercy.



More information about the Digitalmars-d mailing list