Skip Menu |

This queue is for tickets about the Scalar-List-Utils CPAN distribution.

Report information
The Basics
Id: 34544
Status: rejected
Priority: 0/
Queue: Scalar-List-Utils

People
Owner: Nobody in particular
Requestors: brianski [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.19
Fixed in: (no value)



Subject: spurious warnings from reduce
Given the prevalence of strict and warnings, I think something has to be done about the fact that reduce's variables $a and $b aren't "special" in the same way that they are in the builtin sort, for example. ski@ganiodayo:~$ perl -le 'use List::Util "reduce"; use strict; use warnings; print sort { $a + $b } (0,1,1);' 110 ski@ganiodayo:~$ perl -le 'use List::Util "reduce"; use strict; use warnings; print reduce { $a + $b } (0,1,1);' Name "main::a" used only once: possible typo at -e line 1. Name "main::b" used only once: possible typo at -e line 1. 2 ski@ganiodayo:~$ perl -le 'use List::Util "reduce"; use strict; use warnings; no warnings "once"; print reduce { $a + $b } (0,1,1);' 2 I see that the definitinos of sum, etc. via reduce use a similar trick: use vars qw($a $b); But it sure would be nice if "naked" reduce would do "the right thing". Thanks!
Subject: Re: [rt.cpan.org #34544] spurious warnings from reduce
Date: Sat, 29 Mar 2008 18:07:39 -0500
To: bug-Scalar-List-Utils [...] rt.cpan.org
From: Graham Barr <gbarr [...] pobox.com>
On Mar 29, 2008, at 4:16 PM, Brian Szymanski via RT wrote: Show quoted text
> I see that the definitinos of sum, etc. via reduce use a similar > trick: > use vars qw($a $b); > > But it sure would be nice if "naked" reduce would do "the right > thing".
It does do the right thing. Perl has a special case in it parser for $a and $b when seen inside sort. reduce does not have that ability. Graham.
Subject: Re: [rt.cpan.org #34544] spurious warnings from reduce
Date: Sat, 29 Mar 2008 19:21:58 -0400
To: bug-Scalar-List-Utils [...] rt.cpan.org
From: Brian Szymanski <ski-cpan [...] allafrica.com>
Graham Barr via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=34544 > > > On Mar 29, 2008, at 4:16 PM, Brian Szymanski via RT wrote: >
>> I see that the definitinos of sum, etc. via reduce use a similar >> trick: >> use vars qw($a $b); >> >> But it sure would be nice if "naked" reduce would do "the right >> thing". >>
> > It does do the right thing. Perl has a special case in it parser for > $a and $b when seen inside sort. reduce does not have that ability. > > Graham. >
I maintain that it's a problem, although I will concede it is not so much the fault of List::Util as a limitation of perl. Cheers, Brian