Docs: Section on local variables

Jonathan M Davis jmdavisProg at gmx.com
Sat Apr 21 15:08:21 PDT 2012


On Saturday, April 21, 2012 18:26:52 Andrej Mitrovic wrote:
> On 4/21/12, H. S. Teoh <hsteoh at quickfur.ath.cx> wrote:
> > It would be a major pain if every
> > single time you need to temporarily suppress a section of code, you also
> > have to hunt down every last stray variable that's now no longer
> > referenced in the function and comment them out as well.
> 
> Next thing you know the compiler will start warning me when I indent
> my code with uneven number of spaces!

It's not quite as bad as all that. It works reasonably well in Java and C# and 
for the most part isn't a big deal, but for D, init already solves the larger 
problem of variables with garbage values, and adding forced initializations on 
top of that definitely isn't worth it - especially when it requires flow control 
and can give false positives at times.

I don't think that there's much question that Java and C#'s solution is better 
than the lack of one in C/C++. But D already has a solution and does not Java 
and C#'s on top of it.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list