[proposal] version statements with multiple arguments.

Don Clugston dac at nospam.com
Wed Oct 24 02:40:42 PDT 2012


On 23/10/12 05:17, 1100110 wrote:
> Looking at std.io (hopefully the right version maybe?) I see this:
>
> version(OSX)
> {     do something; }
> version(Windows)
> {     do the same thing as above; }
> version(FreeBSD)
> {     ditto; }
> version(Linux)
> {    finally do something different; }
> and:
> version(Windows) version(DigitalMars)
> {     something; }
>
>
> I was rather surprised that this wasn't accepted:
> //Error: found '||' when expecting ')'
>
> version(OSX || Windows || FreeBSD)
> {     do something; }
> version(Linux)
> {     do something different; }
>
>
> The last one could be intuitively described as:
> version(Windows && DigitalMars)
> {     blah;     }

That allows you to create the same bird's nest that you can get with 
#ifdef in C.

See bug 7417 for a different solution that fixes other problems as well.
Just make version declarations behave like bool variable declarations:

version useTheOrdinaryWay = OSX || Windows || FreeBSD;

version dmdWindows = Windows && DigitalMars;
version (dmdWindows) { blah; }






More information about the Digitalmars-d mailing list