null [re: spec#]
Nick Sabalausky
a at a.a
Mon Nov 8 22:21:34 PST 2010
"so" <so at so.do> wrote in message news:op.vlv3iukp7dtt59 at so-pc...
>> There's no usage of an undeclared variable, but the right-hand-side of
>> the
>> second line uses 'i' before *the programmer* initializes it. Yes, the D
>> compiler chooses to automatically initialize it, but by doing so it
>> silently
>> creates a bug every time the programmer intends 'i' to start out as
>> anything
>> other than 0. And it's not easily noticed since 0 is a commonly-used
>> value.
>> (Something like 0xDEADBEEF would at least be an improvement (albeit a
>> small
>> one) since at least that would stand out more and likely fail more
>> spectacularly.)
>
> So you want language force you to type either "int x=0;" or "int x=void;".
> Fair enough and i agree it "might" be a bit better. But you are making it
> as it is something so much important.
I tend to get a bit fired up by it because Walter's reasoning on it being
*better* to automatically assume some init value baffles me.
> Again, for both coder and the code-reader there is no ambiguity here,
> every single thing is defined.
>
Whether or not it's defined isn't really the issue here (although if it
weren't defined, that would definitely be a problem). It just comes down to
"more error-prone" vs "less error-prone".
More information about the Digitalmars-d
mailing list