version vs. static if

Jonathan M Davis jmdavisProg at gmx.com
Fri Sep 23 15:08:20 PDT 2011


On Friday, September 23, 2011 14:54 Nick Sabalausky wrote:
> "Jonathan M Davis" <jmdavisProg at gmx.com> wrote in message
> news:mailman.96.1316813793.26225.digitalmars-d at puremagic.com...
> 
> > On Friday, September 23, 2011 14:14 Nick Sabalausky wrote:
> >> "Adam Ruppe" <destructionator at gmail.com> wrote in message
> >> news:j5iac7$2ole$1 at digitalmars.com...
> >> 
> >> >I hope there's no D3 for a very long time. Maybe 2020.
> >> 
> >> I still hope there is one at some not-too-distant point, though. The
> >> whole
> >> version system really does need an overhaul. One of the big things, if
> >> not
> >> the key one, is that basing it on "symbol defined" vs "symbol not
> >> defined"
> >> (rather than a compile-time bool) is far too problematic.
> > 
> > That's by design. That's the way that Walter wants it. I wouldn't expect
> > that
> > to change in any future version of D unless you can come up with a really
> > good
> > argument to change Walter's mind or someone else takes over as the
> > benevolent
> > dictator at some point.
> 
> Really? I had no idea. What's the reasoning? (I honestly can't imagine
> anything.)

I believe that it comes down to complexity. In C and C++, you get stuff like

#if COND1 || COND2 || (COND3 && COND4)

and it can become fairly easy to screw up when you manage versions that way - 
especially when each of those conditions can be arbitrarily complex _and_ they 
can be affected in entertaining ways by whatever #includes you happen to have 
before them. Simply adding or removing a #include could completely change the 
result of such conditions (as could reordering them in some cases).

By having version restricted to what's defined and having it unaffected by 
imports, it simplifies the situation considerably.

You can still do similarly screwy stuff with static ifs, but if you're using 
version blocks for version stuff and static ifs for templated stuff, then the 
static ifs don't usually get screwy in the same way, and the overall 
situtation is much cleaner.

- Jonathan M Davis


More information about the Digitalmars-d mailing list