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

Re: Idea for new warning - scalar assignment from @_

Thread Previous | Thread Next
Paul Johnson
January 15, 2020 11:56
Re: Idea for new warning - scalar assignment from @_
Message ID:
On Tue, Jan 14, 2020 at 10:41:16AM +0000, Dave Mitchell wrote:
> On Mon, Jan 13, 2020 at 10:16:30PM +0100, demerphq wrote:
> > On Mon, 13 Jan 2020 at 19:38, Paul "LeoNerd" Evans
> [ just repeating here what I added to the github thread]
> While such a warning will of course flush out possible bugs, it will also
> warn on existing perfectly valid code, such as
>     my $nargs = @_;
> A quick CPAN grep of \$\w+\s*=\s*\@_; matches 267 distributions, and
> looking at the first few hits, about 2/3 appear to be valid uses.

I find this argument quite convincing.

I'm not against quite specific warnings but I think I'd also be rather
surprised to find this warning only applicable to @_.  Perhaps that's
partly because I'm not sure I've ever hit Paul's original problem.

Is this a problem which would be entirely fixed with the use of
(expanded?) signatures?

> Coupled with code that may have done "use warnings FATAL => 'all'", there
> is lots of scope for breakage of existing code. So its a -1 from me.

I'm not convinced by the "use warnings FATAL => 'all'" argument though.
There are dire warnings in the docs about doing this and so I really
think that if you do it then you get what you ask for.  We can't keep
painting ourselves into backwards compatibility corners.

Paul Johnson -

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About