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

Deëxperimenting `builtin` functions - shouldimport on `use VERSION`?

Thread Next
Paul "LeoNerd" Evans
August 15, 2023 16:55
Deëxperimenting `builtin` functions - shouldimport on `use VERSION`?
Message ID:
In Perl 5.36 we added the `builtin::` package containing several new
functions. Because they were new, they all raised experimental
warnings at compiletime.

These have remained unchanged through 5.38.

Many of these functions seem quite stable now and it would seem to make
sense to remove the experimental warnings from them. I have a PR to do
just that:

That all feels fairly uncontentious, but the end-goal of `builtin` had
something more in mind. To quote the original document:

  •   Once a stable set of functions is defined, consider creating
      version-numbered bundles in a similar theme to those provided by

        use builtin ':5.40';  # imports all those functions defined by
                              # perl v5.40

  •   Once version-numbered bundles exist, consider whether the main
      `use VERSION` syntax should also enable them; i.e.

        use v5.40;  # Does this imply  use builtin ':5.40'; ?

We could now consider either or both of these things.

I'm a *little* hesitant to just do that though by including every
single non-experimental function in a :5.40 bundle and then having it
imported as part of `use v5.40`, because it feels a bit heavy-handed.
All of a sudden now a `use VERSION` declaration is going to start
pulling in quite a few new functions.

I don't think many folks would have much problem with `use v5.40`
activating the `say` feature and also importing the `true` builtin, as:

    use v5.40;
    say "True is ", true;

But as we continue to add more functions and they become stable, over
time that set of default-imported builtins at the latest version will
continue to grow.

Do we want this? I currently can't think of any particularly
troublesome cases, but I could imagine at some point someone would
object to some particular function being in that bundle because it
conflicted with something else they wanted to do, and thus they
couldn't do `use VERSION` *at all* because of it.

I.e. the trouble with making `use VERSION` do ever-more expanding and
interesting things is that it increases the risk that someone,
somewhere, will find something they object to, and thus can't use it at
all and therefore miss the benefits of it; having to go the long(er)
way around to get the same thing; perhaps a hypothetical

  { use v5.46; }  # to hide the scope of default imports
  use strict;
  use warnings;
  use feature ':5.46';
  use builtin qw( true false blessed reftype ... );
    # all because I didn't want to import  builtin::wibble

Am I just being paranoid here? Perhaps they'd find it good enough to

  use v5.46;
  no builtin 'wibble';

(except that currently unimport of lexicals doesn't exist yet. we
should add that).

What does anyone else think? I'd like to hear arguments for/against such
a `use VERSION` bundling.

Paul "LeoNerd" Evans      |  |

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