On Monday, October 30, 2017 21:47:50 Ola Fosheim Grøstad via Digitalmars-d wrote: > On Monday, 30 October 2017 at 19:51:30 UTC, Jonathan M Davis > > The fact that NaN == NaN is false and yet cast(bool)NaN is true > > though is just attrocious though. We aren't source compatible > > with C like C++ is, and yet we're still bound by it in so many > > small, stupid ways - largely because of the risk of ported code > > going badly. > > I think some of the float semantics aren't in the standard, but > in IEEE754. But many languages have picked up many of C's > not-so-great design characteristics. I think largely because > people who write their own compilers tend to program in C… so > more cultural than rational.
In D's case, Walter consciously tried to make sure that C code was either valid D code with the same semantics or that it wasn't valid D code so that you wouldn't get subtle errors when porting code from C to D. We aren't quite there (e.g. the semantics of a function parameter that's a static array aren't the same), but we're close. His reasoning makes a lot of sense, but it also means that we're still beholden to some of C's unsavory choices - albeit nowhere near as many as C++ is. So, in D's case at least, the decision to match C's semantics was very much rational. However, I'm sure that it's true that a number of the design decisions in D stem from the fact that both Walter and Andrei come from C/C++, and so they're going to tend to make design decisions similar to C/C++ by default. So, D ends up being different when there's a feature that's being purposefully designed to be different from C/C++, but it tends to be similar when there wasn't a strong reason to do something differently from C/C++. - Jonathan M Davis
