float init 0 request
Walter Bright
newshound2 at digitalmars.com
Tue Aug 18 19:24:16 UTC 2026
Thank you for your thoughts on this. It would be even better if there was a
value that would cause an error immediately upon use. We do have that for
pointers! But we don't for floating point (signalling NaNs were discussed
elsewhere), so we just have to do our best.
BTW, the reason ints default initialize to zero is there is no value we can use
as an invalid integer value. Some have proposed int.min, but nothing stops
int.min from being part of a calculation and the result is no longer int.min so
it is likely far more trouble than it's worth.
Designing a programming language is full of compromises. We just have to do the
best we can.
Unlike C, which uses chars as integer types, D has a distinct char type. And so
we can use the "invalid char value", or 0xFF, as its default initializer.
More information about the Digitalmars-d
mailing list