remove keywords

Walter Bright newshound1 at digitalmars.com
Fri Dec 7 02:47:36 PST 2007


mandel wrote:
> For example, one of the motivations was:
> 
> if(bar)
> {
>   version(Foo)
>   {
>      /**/
>   }
> }
> 
> I would rather like to write:
> 
> if(bar && Foo)
> {
>   /**/
> }

The version statement is limited in that you cannot do !foo or 
foo&&bar||baz. Rather than a bug, that is deliberate. I've seen a lot of 
code that, over the years, accumulated detritus like:

     #if FOO || BAR>0x1234 && BAZ && !HACK

These tend to snarl themselves into such a rat's nest of conditionals 
the only way to figure out which lines actually got compiled was to 
examine the preprocessor output. (Another consequence of these is that, 
inevitably, the various conditionals were WRONG as they were layered on 
by people who didn't really understand the code.)

So, by limiting the version statement, the idea is to encourage the 
programmer to think in terms of distinct versions being generated, and 
then code in terms of those distinct versions - each of those versions 
having a name.



More information about the Digitalmars-d mailing list