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

Should we add "builtin" functions for existing core perl operations?

Thread Next
From:
Paul "LeoNerd" Evans
Date:
December 3, 2021 18:26
Subject:
Should we add "builtin" functions for existing core perl operations?
Message ID:
20211203182551.75b75976@shy.leonerd.org.uk
My original thoughts for the `builtin` space, as per RFC 0009, were
simply to add all of the "missing" features that don't actually exist
as real core perl ops, but we think should. Currently it has

  true false isbool

and I have a PR waiting to be reviewed/merged to start bringing in
a few things from Scalar::Util

  weaken unweaken isweak


A few days ago, Graham Knop ("haarg" on IRC) raised an interesting
question on #p5p:

  19:21 <haarg> conceptually, builtin:: is the place for "non-weird"
         core functions

  19:22 <haarg> is the future of builtin:: just the new functions that
         fit that model, or does it make sense to try to apply that to
         the existing functions?

  19:23 <haarg> do we want a builtin::fc ?

  19:23 <LeoNerd> Hrm.. we hadn't mentioned adding existing ones

  19:23 <LeoNerd> On the one hand it does seem a lot of moving for
         little benefit, but on the other it would seem to be the
         "expected" place to find them once you know it exists

  19:23 <LeoNerd> Otherwise there's a bizarre split of which are where,
         based only on the history

  19:24 <haarg> yeah

For example, I'm thinking about what next goes in. Quite likely I'll
bring in `blessed` from Scalar::Util. Now you'd think it would make
sense then to find `bless` in there as well, for the nice symmetry of
being able to

  use builtin qw( bless blessed );

but currently, there isn't a suggested plan to have `bless` available;
after all, it is just a core perl operator already that is always there.


Perhaps we should add it for completeness?

 * On the one hand I think it might be weird to explain to folks "yes,
   bless is available as any of bless(), CORE::bless() or
   builtin::bless()"

 * On the other hand, I think it would be even weirder to explain
   that "if you want blessed you can grab it from builtin::, but if you
   want bless you can't"


What does anyone think here?

(If we had a time machine of course we wouldn't have got into this
 situation in the first place, but since we don't/won't/didn't have
 one, we're stuck with this mess. We don't need a perfect solution, we
 just need to find the least-messy one, accepting that that may still
 have a non-zero amount of mess to it.)

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