float init 0 request
Quirin Schroll
qs.il.paperinik at gmail.com
Mon Aug 17 14:03:46 UTC 2026
On Friday, 14 August 2026 at 06:38:02 UTC, Walter Bright wrote:
> Floats are default initialized to NaN so people will be coerced
> to explicitly code what they want the initialized value to be.
Maybe the next D Edition could require initialization of types
that don’t initialize with a value equal to `0`. D’s behavior
with these is annoying, because leads to needless debug sessions,
and also surprising because no other language that D is similar
to does that: C++. C# and Java all default-initialize to `0`.
Essentially, character and floating-point types should behave
like structs with `@disable this()`.
Of course, as I said, that would be for the next Edition because
it would break code. I don’t know how much existing D code really
uses those initializers, probably some, but very little, because
the defaults are quite useless, intentionally so.
More information about the Digitalmars-d
mailing list