float init 0 request
Walter Bright
newshound2 at digitalmars.com
Wed Aug 19 19:57:57 UTC 2026
Casting is a hammer that overrides the type system. Hence one can plausibly
argue that every cast is a bug in the program, or at least shows the programmer
didn't do a good job selecting types properly. In my own code, I try to select
types to minimize a need for casting.
Implicit conversions, however, are a "soft" conversion rather than a hammer. C
is a bit too loose with that, as such can do hidden truncations. D's design is
better because of Value Range Propagation.
Before C, I programmed in Wirth's Pascal. It all looked good in the manual, but
in practice it was a horrible language. There were no implicit conversions,
everything had to be constantly cast back and forth. So the hammer is
everywhere. I disliked it strongly, and I think that was a big mistake in
Pascal's design.
I've also always disliked C's "char" type because it is how one gets a byte
integer, having nothing to do with characters. D fixes that.
But integral promotions are still retained, because doing integer operations on
char's is not that unusual (such as upper/lower case conversions).
All in all, D's semantic selections for integral types are better than anyone
else's for type safety and convenience.
More information about the Digitalmars-d
mailing list