develooper Front page | perl.perl5.porters | Postings from May 2013

Re: [perl #5087] used only once warning

Thread Previous | Thread Next
From:
Aristotle Pagaltzis
Date:
May 18, 2013 10:54
Subject:
Re: [perl #5087] used only once warning
Message ID:
20130518105427.GA26052@fernweh.plasmasturm.org
* Ricardo SIGNES via RT <perlbug-followup@perl.org> [2013-01-05 20:25]:
> When I wrote about this todo a while ago, I suggested that assigning
> to a lexical was enough to indicate that it was used.  For example,
> "my $exit = Scope::Guard->..." is useful, even if you don't mention
> $exit again.  Similarly, "my ($self, @x) = @_" is not madness.
>
> This does mean that we're detecting fewer actually bogus cases.  We'd
> only get variables declared and use never, rather than used once.
> (my $x;)
>
> Is that sufficiently useful to pursue?  I'm not sure.

I feel it would be.

But at that point we are also talking about wholly different concepts:
“declared but never used” vs “used only once”. It would be strange for
the warning to be thrown if you assign to a global but not if you assign
to lexical, yet at the same time be thrown if you declare a lexical but
never assign to it which for globals is obviously a nonsensical concept.
Clearly there are two different types of occasion here.

So if something is to be implemented for lexicals then it really ought
not to be the same warning.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About