version: multiple conditions

Daniel Murphy via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 25 23:06:10 PDT 2015


"Walter Bright"  wrote in message news:mloslo$1o7v$1 at digitalmars.com...

> I have yet to see a single case of "needing" boolean versions that could 
> not be refactored into something much more readable and maintainable that 
> did not use such.
>
> Over time, I've gotten rid of most of that stuff from the dmd source code, 
> and the result has been quite pleasing.

Walter, how about a compromise?

If we allow setting versions to boolean expression then it becomes much 
easier to use it the way you suggest, while still requiring a (hopefully) 
sensible name and discouraging making a mess.

eg

version(A)
{
   version(B)
   {
   }
   else
   {
      version=NeedsSomeCode;
   }
}

becomes

version NeedsSomeCode = A && !B

An example from real code would be

version valistIsCharPointer = (Linux && LP32) || Windows;

This pattern does appear frequently in your compiler code, are you for or 
against seeing it in D? 



More information about the Digitalmars-d mailing list