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

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

Thread Previous | Thread Next
From:
Yuki Kimoto
Date:
September 1, 2021 00:50
Subject:
Re: PSC #034 2021-08-20 - "Namespaces Special"
Message ID:
CAExogxNevWj0f-Bd=wdLp5X7-SEay2A29pO2esaHSUbNVoSEKA@mail.gmail.com
2021-9-1 0:06 demerphq <demerphq@gmail.com> wrote:

> 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/"
>

demerphq. Thank you for your reply.

I would like to confirm with an expected example.

Perl 5.40 implements the following functions.

builtin::foo
builtin::bar
builtin::baz

  use v5.40;

  # OK
  builtin::foo
  builtin::bar
  builtin::baz

  # Not OK
  foo
  bar
  baz

Perl 5.42 decides builtin::foo should be into CORE namespace.

  use v5.42;

  # OK
  builtin::foo
  builtin::bar
  builtin::baz
  foo

  # Not OK
  bar
  baz

Is the Perl core team aiming for something like this?

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