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

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

Thread Next
From:
Paul "LeoNerd" Evans
Date:
August 15, 2023 16:55
Subject:
Deëxperimenting `builtin` functions - shouldimport on `use VERSION`?
Message ID:
20230815175512.265dbc48@shy.leonerd.org.uk
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:

  https://github.com/Perl/perl5/pull/21330

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
      feature.pm:

        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

leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

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