Stroustrup's slides about c++11 and c++14

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Sat Sep 13 17:12:14 PDT 2014


On 09/13/2014 10:10 PM, eles wrote:
> ...
> But the surprise comes at the end (slide 57), where he also
> criticizes... the static if ...
>
> Are those points valid?:
> ...
> • Unstructured, can do everything (just like goto)
> • Complicates static analysis (AST-based tools get hard to write)
> • Blocks the path for concepts
> • Specifies how things are done (implementation)
> • Is three slightly different “ifs” using a common syntax
> • Redefines the meaning of common notation (such as { ... })

In D, { ... } has this other meaning even without static if and I would 
say similar syntax rather than common syntax and leave out the pointless 
reference to goto.

Otherwise, yes. In exchange you get static if. :o)

However, as Peter points out, static if as implemented in DMD currently 
has some serious issues:

static if(!is(typeof(x))) enum y=2;
static if(!is(typeof(y))) enum x=1;

This code is ambiguous: It could define either x or y.

If the two static if's are defined in different modules that import each 
other, then the order those modules are passed to DMD on the command 
line can influence which of x or y ends up being defined.

The problem is that DMD does not seem to have a coherent way of 
resolving dependencies. (My own project does not compile with versions 
of DMD after 2.060, and even with 2.060, I had to move code around 
randomly. I think it will be easily fixed to compile again only when 
analysis dependency management is fixed in a good enough way.)



More information about the Digitalmars-d mailing list