On Saturday, 9 March 2013 at 14:09:39 UTC, Andrei Alexandrescu
wrote:
On 3/8/13 7:48 PM, DypthroposTheImposter wrote:
See the static_if paper here:
http://isocpp.org/forums
Under the post "constraints and static if" there is a link to a
document about
static_if
https://docs.google.com/viewer?a=v&pid=forums&srcid=MDIyMDc3NjUwMTczOTM0Mjk3NjABMDI2MzM3MjkxNDM4NDQ5MzE4NDcBLWVsS1Y4dFhtdDhKATUBaXNvY3BwLm9yZwF2Mg
Are they full of it? Has it caused the problems they mention
in
D?
Wow. That's quite out of character for Bjarne. I think it's
quite a poor piece.
Andrei
I think there is a bit of forced bashing in there, but the main
point is that static if prevents eager semantic validation of
templated code. In C++, if you write a semantically incorrect
template, then the compiler can catch it. This is not possible
once static ifs enter the picture.
I know for a fact I've had the C++ compiler catch a fair amount
of errors for me, whereas it takes actual intantiation for the D
compiler to catch said errors (and I've seen a few such errors in
phobos).
I think the main point is not "is static if good or not": I think
D has clearly demonstrated how powerful it can be. However, to
the question of "is it the right move for C++, whith all of its
heritage, to adopt static if?" As a C++ developper, honestly, I'm
not sure it is. I think that's where the piece is comming from,
in maybe a clumsy manner.
C++ took a different road with its "horrible" template syntax,
but it took that road. I think it is better to improve that road
(with concepts, for example), then try to move the current
paradigm.
That's might point of view having mostly a "full C++" background,
and having learned D. The bottom line, I think, is that it is an
error to think of D as "just" improved C++, and that what might
work for D might not be what is best for C++. It doesn't mean
that static if (or other D constructs) are bad in and out of
themselves. I wouldn't take this piece as a "direct attack" on D.
...
BTW, in regards to template constraints (not the rest), he does
have a point. We have raised the exact same issues here on the
boards more than once.