"H. S. Teoh" <[email protected]> wrote in message news:[email protected]... > On Sat, Apr 21, 2012 at 02:14:14AM -0700, Jonathan M Davis wrote: >> >> init solves the larger problem of uninitialized variables being >> garbage and resulting in non-deterministic behavior. And it solves it >> in more places than the Java and C# solution does, because it deals >> with stuff like initializing all of the elements in an array when it's >> first allocated, which they don't AFAIK. >> >> True, init doesn't make it so that programmers always remember to >> initialize all of their variables, and with a default-initialized >> variable, you have the ambiguity of whether the programmer meant to >> use the default or whether they forgot to initialize the variable, but >> that's minor in comparison to uniitialized variables being garbage >> values. And since there's nothing to stop a programmer from >> initializing a variable with an incorrect value, the fact that a >> variable is directly initialized by the programmer in Java and C# >> doesn't necessarily solve that problem any better anyway. And then >> there's also the irritation of the occasional forced initialization, >> because the compiler's flow analysis isn't good enough to detect that >> it's unecessary. > [...] > > Hold on a second here, I thought the original complaint was that > *unused* local variables should generate a warning? What has that got to > do with .init? [...]
There were two original points. Warnings on unused locals was one. The other was this which, apperently, is still in the docs from, what, almost a decade ago?: "Local Variables It is an error to use a local variable without first assigning it a value. The implementation may not always be able to detect these cases. Other language compilers sometimes issue a warning for this, but since it is always a bug, it should be an error." > > -- > "You are a very disagreeable person." "NO." That reminds me of one of mine, which I kinda liked at first, but then was never really sure the intended irony of "agreeable asshole" came across quite like it was supposed to: https://www.semitwist.com/articles/article/view/seriously-do-i-even-read-any-of-the-crap-i-write... (Ugh, the trailing dots are apperently part of the URL. Stoopid off-the-shelf CMS...)
