What's the replacement for this array initialization: "ubyte[4096] window =0;"
monarch_dodra
monarchdodra at gmail.com
Thu Feb 21 23:02:14 PST 2013
On Friday, 22 February 2013 at 04:10:52 UTC, Marco Leise wrote:
> So I'm wondering to do this now. I want to be explicit so a
> reader knows I explicitly set the initial value of this array
> in that structure to all zeros. My argument is that D
> initializes not with the most convenient, but the most wrong
> value in order to provoke reproducible errors. So in general
> you should initialize to sane values.
That's not entirely true. For integers, the initialization is
always 0, which is expected and convenient.
For characters, it's 0xFF, because what else are you going to
initialize it to? space? Given there is no standard default
initial value, D chose the mostest garbage value possible (but in
a defined behavior).
As for floats, well, arguably, I prefer the NaN behavior, because
floats are very strange beasts, and the initialization scheme
reminds me that there are many many many pitfals to remember.
More information about the Digitalmars-d-learn
mailing list