Docs: Section on local variables
Andrej Mitrovic
andrej.mitrovich at gmail.com
Wed Apr 25 14:55:31 PDT 2012
On 4/25/12, Stewart Gordon <smjg_1998 at yahoo.com> wrote:
> What is the distinction you're making exactly?
> You mean an empty if body should trigger something? Or shouldn't?
I'm saying those are exactly the cases presented in the docs and I
don't want them to warn by default but have a setting. I mean, the
first case (warn on unused variables), I just might get used to. But
warning on reading before writing is an extreme change from current
behavior imho.
> Sometimes a constructor may hook the object up to
> something.
Yup. E.g.:
class Foo
{
static Foo[] objects;
this()
{
objects ~= this;
}
}
IIRC I've seen this used in Harmonia and maybe in some places on some
github project (I think it was actually the D forum software). The
compiler might not even know what the ctor does if all it has is the
.di file of the module where the class is defined.
More information about the Digitalmars-d-learn
mailing list