More operators inside `is(...)` expressions

Steven Schveighoffer schveiguy at
Tue Sep 1 14:00:19 UTC 2020

On 9/1/20 9:32 AM, Ogi wrote:
> On Tuesday, 1 September 2020 at 09:05:27 UTC, Jacob Carlborg wrote:
>> On Tuesday, 1 September 2020 at 07:11:45 UTC, Ogi wrote:
>>> Why use `version` then?
>> Because that's set automatically by the compiler. Here's a list of the 
>> predefined version identifiers set by the compiler [1].
>> [1]
>> -- 
>> /Jacob Carlborg
> I am aware of that. I mean that the enum workaround for version 
> condition is the indication of its poor design.
> The syntax is unreasonably restrictive. I can see the point of 
> prohibiting complex expressions (like `version (Windows || (POSIX && 
> !LDC))`), but something as simple as version(!Windows) would be harmless.

In fact, I think version(a || b) would be the only thing we need to add, 
as the code you need to write to reproduce such a thing is horrendous, 
and the alternative is duplicating code.

You can already do version(a) version(b) to get the effect of &&.

`Not` is problematic, because you should really write code based on what 
the version is, not for everything else (for the most part), and the 
"not" can also be done via the slightly ugly but still reasonable 
version(x) {} else ...

But Walter is never going to approve any changes here, as this is one 
area where he will not budge, due to past experience with the C 
Preprocessor abuse. So this discussion is only academic. Just use the 
workarounds and move on.


More information about the Digitalmars-d mailing list