develooper Front page | perl.perl5.porters | Postings from January 2018

Re: [perl #5087] used only once warning

Thread Previous | Thread Next
From:
Sawyer X
Date:
January 20, 2018 20:30
Subject:
Re: [perl #5087] used only once warning
Message ID:
9eb63a7e-e9d2-5f67-eda8-cf3ac189e986@gmail.com


On 01/19/2018 11:24 PM, Abigail via RT wrote:
> On Sat, 05 Jan 2013 11:20:05 -0800, rjbs wrote:
>> On Fri Dec 14 07:36:17 2012, nicholas wrote:
>>> On Wed, Dec 12, 2012 at 01:15:39PM -0500, Peter Martini wrote:
>>>
>>>> Right.  Can the ticket be closed for that reason then?  There is an
>>>> implementation of a module to do this on cpan, and a note on this
>>>> warning
>>>> in the docs wouldn't hurt.
>>> I think fix the documentation to be clear on the "what" and the
>>> "why", then
>>> close the ticket.
>> 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.
>
>
> But declaring variables, and never using them can still be very useful.
>
> This is how I write new() in my objects:
>
>     sub new ($class) {
>         bless \do {my $var} => $class;  #  Or bless do {\my $var} => $class
>     }

Out of curiosity, what's the benefit of this?

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