Docs: Section on local variables

Andrej Mitrovic andrej.mitrovich at gmail.com
Thu Apr 19 18:22:43 PDT 2012


Can we remove this section from the D docs, in the functions section? :

"
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.

It is an error to declare a local variable that is never referred to.
Dead variables, like anachronistic dead code, are just a source of
confusion for maintenance programmers.
"

I don't think this will ever be implemented, or that it should be for
that matter. The first paragraph is quite extreme. As for the second
one, think about how often you use temporary variables just to test
something out, you wouldn't want to have a compilation error just
because you've temporarily left an unused variable inside a function.
That's my experience anywho..

I think these features probably belong to some lint-type tool and not
the compiler.


More information about the Digitalmars-d mailing list