[Pdx-pm] fun with import()
chromatic
chromatic at wgz.org
Sun Aug 6 13:45:00 PDT 2006
On Sunday 06 August 2006 11:04, Eric Wilhelm wrote:
> If any module anywhere does "use UNIVERSAL;" or "require UNIVERSAL",
> everyone automatically is using Exporter::import() unless they
> explicitly declared their own import sub. Bug?
Yep, and a nasty one as it allows you to say:
use UNIVERSAL 'isa';
... and:
use UNIVERSAL 'can';
... and pretend as if isa() and can() are functions. (They're not. Is anyone
getting tired of hearing me say this yet? Tell your friends.)
The comment in UNIVERSAL.pm reads:
# The use of Exporter below is a historical
# accident that can't be fixed without breaking code. Note that we
# *don't* set @ISA here, don't want all classes/objects inheriting from
# Exporter. It's bad enough that all classes have a import() method
# whenever UNIVERSAL.pm is loaded.
I did fix the documentation in bleadperl to suggest therapy instead of
importing isa() and can(); I'm not sure if it went into maintperl at some
point.
-- c
More information about the Pdx-pm-list
mailing list