Version Identifiers for Platforms / Architectures not supported byDMD
kennytm
kennytm at gmail.com
Wed Nov 9 20:07:43 PST 2011
Walter Bright <newshound2 at digitalmars.com> wrote:
> 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.
Perhaps DMD should generate a warning if a version of platforms does not
have an else clause or that version's else clause's content is not another
version statement or a static assert.
More information about the Digitalmars-d
mailing list