version: multiple conditions

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 4 23:05:01 PDT 2015


On Saturday, 4 July 2015 at 22:43:40 UTC, Walter Bright wrote:
> On 7/4/2015 2:24 PM, Joakim wrote:
>> I agree that mistyping and checking a large array of
>> version constants can cause problems
>
> It's one reason why this style is recommended:
>
>     version (linux)
>     {
> 	...
>     }
>     else version (Windows)
>     {
> 	...
>     }
>     else
> 	static assert(0);

Yeah, and while version identifiers can certainly be error-prone, 
it's not like allowing arbitrary conditions or even &&ing and 
||ing version identifiers would make them _less_ error-prone. 
We're dealing with the type of thing that seems to just be 
fundamentally error-prone such that the best that we can do is 
disallow some of the worst cases and adopt practices which 
mitigate the risk. We _do_ need version statements (or an 
equivalent) though, otherwise it would be be pretty hard to write 
cross-platform code.

- Jonathan M Davis


More information about the Digitalmars-d mailing list