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

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

Thread Previous | Thread Next
From:
demerphq
Date:
August 31, 2021 15:07
Subject:
Re: PSC #034 2021-08-20 - "Namespaces Special"
Message ID:
CANgJU+VXq2jZwvWXATPAOVWiOJwA9j+n1fuJ6XZRsrTkuEiSqw@mail.gmail.com
On Mon, 30 Aug 2021 at 05:46, Yuki Kimoto <kimoto.yuki@gmail.com> wrote:

>
> 2021-8-27 21:08 Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> wrote:
>
>>
>>         #!perl
>>         use v5.40;
>>         say "The reftype of arrays is ", reftype [];
>>
>>
>>
> There is one point I would like PSC to add to the discussion.
>
> Are all builtin functions imported to the "main" namespace?
>

No. That is the point of having a different namespace that is reserved for
this purpose. Functions would be imported from the "builtin" namespace
(whatever that  might be) similarly to any other import. And in the  shim
logic they might imported into the builtin namespace for you, as well as
optionally imported into your package.

eg: consider:

use builtin v5.32; # ensure that this perl has the builtin's necessary to
similute 5.32's set of functions

versus:

use builtin v5.32 qw(whatever); # ensure that this perl has the builtin's
necessary to simulate 5.32's functions, and import "whatever".

The former would ensure that builtin::whatever would be available assuming
it was part of 5.32's functions. The latter, would do the same but also
export "whatever" into your namespace. The version might be mandatory, so
that if you say:

use builtin v5.32 qw(whatevr); # ensure that this perl has the builtin's
necessary to simulate 5.32's functions, and try to import "whatevr".

we can do an error message like one of the following:

"Function "whatevr" is not a valid function from the v5.32 builtin
namespace, this either means this function was introduced in a later
version, or it means you have typoed the function name".
"This person does not have the shim modules in place to support v5.32
builtin namespace, install the latest version of the "builtin"
distribuition from CPAN"

depending on whether their perl is newer than 5.32 or if they have the
latest version of the builtin backcompat layer (however that might work in
practice).

cheers,
Yves


-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

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