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

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

Thread Previous
From:
Jim Avera
Date:
April 30, 2018 05:20
Subject:
Re: [perl #133161] Anythingatall->import gives no error
Message ID:
21fd3ea6-0943-bc6f-48e0-e8d5bc4af5c4@gmail.com
AFAIK this is not documented (the docs say there is absolutely nothing 
special about 'import').

Maybe this should be mentioned in perlmod.

-Jim

On 4/29/18 10:07 PM, Dan Book via RT wrote:
> 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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About