develooper Front page | perl.perl5.porters | Postings from August 2021

Re: PSC #034 2021-08-20 - "Namespaces Special"

Thread Previous | Thread Next
From:
Eirik Berg Hanssen
Date:
August 30, 2021 10:21
Subject:
Re: PSC #034 2021-08-20 - "Namespaces Special"
Message ID:
CAHAeAG7wv4GhonCnGQG5ky-uGmdWf=MkN_dAG3d1b3+xtbLN9w@mail.gmail.com
On Mon, Aug 30, 2021 at 10:02 AM Yuki Kimoto <kimoto.yuki@gmail.com> wrote:

>
> 2021-8-30 14:12 Dan Book <grinnz@gmail.com> wrote:
>
>> On Mon, Aug 30, 2021 at 1:09 AM Yuki Kimoto <kimoto.yuki@gmail.com>
>> wrote:
>>
>> Imported symbols override builtins already, this is how modules like
>> autodie and Time::HiRes work. But yes, this chance of collision is
>> unavoidable and we have to take more care with more common names.
>>
>> -Dan
>>
>
> > Imported symbols override builtins already
>
> Is this really?
>
>   perl -E 'sub substr { print "substr\n" }; substr();'
>
> Output
>
>   Not enough arguments for substr at -e line 1, near "substr()"
>   Execution of -e aborted due to compilation errors.
>
> Imported symbols don't seem to override CORE::substr,
>

  That's not actually imported though.

$ perl -E 'BEGIN { package foo; *::substr=sub { print "substr\n" } }
substr();'
substr
$

  Yes, it needs that package declaration …


Eirik

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