develooper Front page | perl.perl5.porters | Postings from December 2017

Re: [perl #132425] Suggested warning on attempt to 'use' witharguments when no import() subroutine exists

Thread Previous | Thread Next
From:
Zefram
Date:
December 12, 2017 01:41
Subject:
Re: [perl #132425] Suggested warning on attempt to 'use' witharguments when no import() subroutine exists
Message ID:
20171212014119.GA26364@fysh.org
Ed Avis wrote:
>If a module doesn't define an import subroutine, but the caller tries
>to 'use' that module specifying an import list, this should generate a
>warning.

I'm not interested in this warning per se, but it seems like
an excellent thing to deprecate.  I have implemented on branch
zefram/deprecate_some_fake_import a deprecation of (a) calls to undefined
"import" methods with arguments and (b) all calls to undefine "unimport"
methods.

We can expect that this deprecation wouldn't get triggered very much, and
that almost all things that hit it would actually be bugs.  It reveals a
handful of bugs in the core distro, for example that Porting/GitUtils.pm
doesn't declare a package and so drops its subs straight into the main
package (which accidentally works, because that's where the caller wanted
to import them).

A few days ago I had a stab at a more radical deprecation that would also
cover no-args calls to "import" methods, but that produces a surprisingly
large amount of noise.  Of course it would be deprecating some things that
are not bugs, because of the use of "use Some::Class;", but I was taken
aback at how numerous they were.  The deprecation that I'm proposing
now doesn't touch that usage at all.  I'd still like to tackle no-args
"import" calls in some way in the future, because the current behaviour
hides bugs involving mismatched package names, but it would require a
more nuanced approach.  In any case, that's for a future decision.

If there's a consensus that this deprecation is in principle a good idea,
then there's nothing preventing us merging this for 5.28.

-zefram

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