Floating point values in structs.
Adam D. Ruppe
destructionator at gmail.com
Fri Dec 18 16:23:20 UTC 2020
On Friday, 18 December 2020 at 16:18:12 UTC, Dave P. wrote:
> Is the proper solution to change the struct definition to:
yeah that's the best option right now
> I find the setting floats to nan pretty bizarre.
yeah i wrote about it here not long ago
http://dpldocs.info/this-week-in-d/Blog.Posted_2020_11_23.html#looking-back
excerpt:
"See, the idea behind D's initialization is it catches
uninitialized values at runtime. Null pointers crash. NaN floats
give NaN results. \ff chars give invalid strings.
The problem is it sets the initializer for int (and friends) to
be 0. Which is actually pretty useful and convenient, so people
rely on it. Now making uninitialized things an error is
infeasible and the fact is it sets a habit to expect 0."
so i think it should be changed. but floats and chars are all
weird initialized so be aware of it
More information about the Digitalmars-d-learn
mailing list