On Sun, Mar 25, 2012 at 03:31:30PM -0400, Gisle Aas via RT wrote:
Show quoted text> <URL:
https://rt.cpan.org/Ticket/Display.html?id=72505 >
>
>
> On 25. mars 2012, at 18:34, Eric Brine wrote:
>
> > On Sun, Mar 25, 2012 at 10:40 AM, Gisle Aas <gisle@activestate.com> wrote:
> > This was was perfectly fine code that I now had to change because of this warning.
> >
> > As you can see there are certainly valid uses of length(@array). I would prefer for that warning to not be there.
> >
> > There are certainly valid uses of numification of non-numeric
> > strings, stringification of undef, deep recursion, ambiguous use of
> > operators, etc, but those warn too. The criteria isn't whether it
> > has valid uses or not, it's a question of how many time it's used,
> > and for what percentage of those times it's used incorrectly.
>
> It's not so problematic for me that there are warnings for run-time
> conditions that might indicate errors. These are conditions that the
> programmer might not have expected and it's good to make her be
> explicit about it. But complaining about length(@array) is a pure
> static warning. If we don't want people to be able to say that, why
> not just make it a syntax error then? We can even introduce this
> using a feature to stay backwards compatible.
Making it a syntax error would not be in line with our deprecation
policy. Deprecating existing syntax requires a warning for at least one
full stable release cycle before we can actually make it an error.
Show quoted text> I don't think I ever seen a program that use length(@array)
> incorrectly. Are we for instance able to point to code on CPAN that
> use this construct incorrectly?
I can see quite a few misuses of length(@array) in
http://grep.cpan.me/?q=%5Cblength%5C%28%5C%40
Show quoted text> I'm sure there have been novice Perl programmers that have attempted
> to write length(@array) when they shouldn't, but the error would be
> pretty obvious from the result you get.
Only if the code is on a common execution path which is actually tested
(and if the test actually would be different - testing length(@a) == 1
would succeed in both interpretations, for instance).
-doy