In perl.git, the branch smoke-me/avar/universal-no-import has been created

<http://perl5.git.perl.org/perl.git/commitdiff/8804321d1a2f6e0eec133ffb898f7b73d39de547?hp=0000000000000000000000000000000000000000>

        at  8804321d1a2f6e0eec133ffb898f7b73d39de547 (commit)

- Log -----------------------------------------------------------------
commit 8804321d1a2f6e0eec133ffb898f7b73d39de547
Author: Ævar Arnfjörð Bjarmason <[email protected]>
Date:   Mon Sep 26 10:59:13 2016 +0000

    UNIVERSAL: Make "use UNIVERSAL" croak without making $pkg->can("import") 
true everywhere
    
    In 5.12.0 doing "use UNIVERSAL (...)" would start warning that you
    shouldn't use it (1d9f57d), then since v5.22.0 it's been dying when
    you do that (v5.21.2-13-g1178d2c).
    
        http://perldoc.perl.org/perl5120delta.html#Deprecations
        
http://perldoc.perl.org/perl5220delta.html#use-UNIVERSAL-'...'-is-now-a-fatal-error
    
    This change makes both "use UNIVERSAL" and "no UNIVERSAL" die. This
    doesn't currently die and *will* break some code on the CPAN:
    http://grep.cpan.me/?q=use%5Cs*UNIVERSAL%3B
    
    The reason I'm doing this is because I had UNIVERSAL::import in my
    code by just doing:
    
        use UNIVERSAL ();
    
    As some distros like IPC::Run pointlessly
    do (https://rt.cpan.org/Ticket/Display.html?id=118082) would make
    $pkg->can("import") true for any value of $pkg, which trips up any
    code that for whatever reason wants to know if there's an existing
    "import" method in a package, e.g. my own Constant::Export::Lazy:
    https://metacpan.org/pod/Constant::Export::Lazy#wrap_existing_import
    
    The reason for the comment about the import() being a historical
    accident that we can't remove is because of (via #p5p on Fri Jul 15
    2016):
    
        08:05 < avar> ilmari: Why is the existence of UNIVERSAL::import()
        something that can't be removed without breaking code? You
        mentioned that in 1178d2c
        [...]
        14:38 < ilmari> avar: I should have reworded that comment
        better. the import needs to exist to get an error message when
        trying to import something
        14:39 < ilmari> otherwise use UNIVERSAL 'foo'; would just silently
        do nothing (unless we delete UNIVERSAL.pm)
        14:39 < ilmari> that might be something to consider doing after
        it's been erroring for a sufficient number major releases
    
    The reason I'm not just deleting UNIVERSAL.pm (and moving the docs to
    a UNIVERSAL.pod) is because that would then die with the way more
    confusing:
    
        $ ./miniperl -e 'use UNIVERSAL'
        Can't locate UNIVERSAL.pm in @INC (you may need to install the 
UNIVERSAL module) (@INC contains: .) at -e line 1.
    
    As opposed to now:
    
        $ ./miniperl -Ilib -e 'use UNIVERSAL'
        Can't locate object method "import" via package "UNIVERSAL" at -e line 
1.
    
    I *could* patch the core to make *that* a special case, but not only
    would that cause even more unexpected nastyness (e.g. you couldn't
    provide your own UNIVERSAL.pm if you wanted in your $PERL5LIB), but
    more importantly "use UNIVERSAL ()" while pointless wasn't the thing
    that was deprecated in v5.12.0 & v5.22.0, only actually calling the
    "import" method with an argument.
    
    I'm making the "unimport" method have the same error while I'm at it,
    while that was never technically deprecated, I can't imagine that
    anyone will mind, and it makes the patch to gv.c easier.
-----------------------------------------------------------------------

--
Perl5 Master Repository

Reply via email to