develooper Front page | perl.perl5.porters | Postings from April 2018

Re: [perl #133161] Anythingatall->import gives no error

Thread Previous | Thread Next
From:
Dan Book
Date:
April 30, 2018 05:07
Subject:
Re: [perl #133161] Anythingatall->import gives no error
Message ID:
CABMkAVUtpsu=Z2nCoXiVdG292tE_czmBGdhWhPbUXeQej9cyPg@mail.gmail.com
On Sun, Apr 29, 2018 at 10:34 PM, Jim Avera (via RT) <
perlbug-followup@perl.org> wrote:
>
>
>          Misspelled->import;
>
> Always silently succeeds.
>
> Shouldn't this cause
>   Can't locate object method "import" via package "Misspelled" ...  ?
>

The import method is special cased to do nothing when it doesn't exist, in
order for "use" to not throw errors when a package doesn't implement it.
Interestingly, methods in UNIVERSAL also don't end up throwing errors since
they just use the default implementation even if the package doesn't exist.

Foo->DOES('Foo') # 1
Foo->can('can') # returns a coderef

-Dan

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