Version Identifiers for Platforms / Architectures not supported byDMD

Alex Rønne Petersen xtzgzorex at gmail.com
Wed Nov 9 05:34:44 PST 2011


On 09-11-2011 02:29, Daniel Murphy wrote:
> There is always one backwards compatible solution:
>
> We could make version identifiers case insensitive.

That's not backwards-compatible. What if someone out there is really 
using Foo and fOO for two different things? I know this sounds 
far-fetched, but the possibility is there.

>
> It's a change from everywhere else in the language, but...
>
> There is no 'correct' casing for os/architecture etc
> windows vs Windows, linux vs Linux, x86 vs X86 are meaningless distinctions.

It's proper spelling of the titles of the architectures/OSs. I don't see 
how this is not correct.

>
> Invalid identifiers are _silently_ accepted.
> eg.
> version(Linux) {}
> Would anybody ever _actually_ mean Linux here?

Maybe... they could have:

version (linux) { version (Linux); }

to fix the inconsistency that is in place now. ;)

>
> Because it works on a is/is not defined basis, this is one case where case
> sensitivity harms usability.  You never get an error for messing up the
> casing, unless you explicitly add a static assert in an else clause.

Very true. But you're supposed to do that anyway, as Walter pointed out 
in a post to the druntime mailing list, because it aids portability.

>
> Does anybody really define both 'MyVersion' and 'myVersion' and expect them
> to do different things?
>
> I think the inconsistency and the small addition to the spec are worth it to
> have the compiler silently and automatically do the right thing, and remove
> the impact of some incredibly inconsistent and arbirtary casing choices.
>
>

In general, I agree, but this would be a breaking change no matter how 
you look at it. I'm not sure if that's a good idea.

- Alex


More information about the Digitalmars-d mailing list