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!