Section on local variables

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Fri Apr 20 02:46:58 PDT 2012


"Andrej Mitrovic" <andrej.mitrovich at gmail.com> wrote in message 
news:mailman.1946.1334885029.4860.digitalmars-d at puremagic.com...
> 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.
>

Wow, as much as I like it, that's very non-D-like. C# has it which I always 
liked. But from discussions, Walter seemed very much against it. So I'm very 
surprised that's even there.

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

We don't even have a warning for that. (I've asked for one ages ago, but I 
don't think it's gonna happen: 
http://d.puremagic.com/issues/show_bug.cgi?id=2197  - I don't know what the 
hell I was thinking with that over-contrived example though) I wouldn't want 
it to be an error, because like you said, that'd be a PITA for temporary 
code paths, but I always felt it would be helpful as a warning. But, 
uhh...someone...hates warnings though... ;)




More information about the Digitalmars-d mailing list