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

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

Thread Previous | Thread Next
Dan Book
April 30, 2018 05:07
Re: [perl #133161] Anythingatall->import gives no error
Message ID:
On Sun, Apr 29, 2018 at 10:34 PM, Jim Avera (via RT) <> 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


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