"so" <s...@so.do> wrote in message news:op.vlua80b47dt...@so-pc... >> I think I figured out what you meant. When I said "C# got it right", you >> thought I was talking about how C# doesn't allow any "int x = void;" >> whatsoever, right? That's not what I meant. I was talking about how C# >> issues a compile-time error whenever a variable is read before it's >> guaranteed to have been written (at least for local vars, I don't >> remember >> how it handles member vars). > > That too, and i am having hard time understanding the other as well, that > i thought you mean "int x;" can cause bugs but not "int x=0;" > and compiler should track "int x;" >
Example: // Returns: Needs another pass? bool process(ref int a) {...} // Process arr in reverse order. // Certain elements may need more than one pass. void foo(int[] arr) { int i; // Oops! Meant "int i = arr.length;" while(i > 0) { bool shouldReprocess = process(arr[i]); if(!shouldReprocess) i--; } } Yes, there are probably other ways to write that, but the basic idea is that bugs can be caused by D's automatically assuming you wanted to initialize to a certain value. Requiring you to actually say what value you want to start with would give the programmer a chance to avoid these problems. Walter is worried that this would cause certain programmers to blindly toss in something like "= 0". I say, if that's a bad thing to do, then why in the world should the compiler AUTOMATE that exact same bad idea?