version vs. static if

Nick Sabalausky a at a.a
Fri Sep 23 16:21:50 PDT 2011


"Sean Kelly" <sean at invisibleduck.org> wrote in message 
news:mailman.107.1316819890.26225.digitalmars-d at puremagic.com...
>On Sep 23, 2011, at 3:30 PM, Nick Sabalausky wrote:
>>
>> But version is *not* restricted to what's defined. It *also* deals with
>> what's *not* defined. That's the main problem I'm talking about.
>>
>> If Walter wants to limit the logic operations and import implications, 
>> none
>> of that necessitates that the version identifiers be based on "defined vs
>> undefined".
>>
>> What I mean is this: Using an undefined version identifier should be an
>> error:
>>
>> version(ThisIsNeverDeclaredAnywhere) {} else {}
>>
>> That is currently accepted, but it should be a compile-time error.
>
>I'm not sure I understand.  If this were the case, how could we use 
>version(Windows) etc in our code?=

That would be a built-in. It would be defined as "true" on Windows and 
"false" on non-Windows. Then:

version(Windows) {} else {}

But that difference with that, being that it's a built-in, these would be 
illegal (because they would be re-definitions of an already-defined version 
identifier):

version Windows = ...;
>dmd -version:Windows
>dmd -versionoff:Windows




More information about the Digitalmars-d mailing list