float init 0 request
Indraj Gandham
newsgroups at indraj.net
Mon Aug 17 14:43:00 UTC 2026
On Monday, 17 August 2026 at 14:03:46 UTC, Quirin Schroll wrote:
> 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.
Very little code would be impacted, as shown by OpenD's
successful change from NaN to 0.0, a small QoL improvement which
could be implemented in upstream today (but won't be).
More information about the Digitalmars-d
mailing list