On Monday, 30 October 2017 at 19:51:30 UTC, Jonathan M Davis wrote:
Yeah. Honestly, I stay away from if(x) in general if x isn't a bool.

That's the best option, even for ints. The proper way to cast to bool is to be explicit. A lot of the shorthand in C probably had to do with early CRTs not being able to display a lot of text. At this day and age readability (easy to scan quickly) should be more important than terseness.

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.

Reply via email to