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

Re: Looking for someone to adopt adding trim() to core

Thread Previous | Thread Next
From:
H.Merijn Brand
Date:
February 15, 2021 15:11
Subject:
Re: Looking for someone to adopt adding trim() to core
Message ID:
20210215161134.0a9d8428@pc09.procura.nl
On Mon, 15 Feb 2021 15:53:09 +0100, "Christian Walde"
<walde.christian@gmail.com> wrote:

> On Mon, 15 Feb 2021 12:44:58 +0100, demerphq <demerphq@gmail.com>
> wrote:
> 
> > [...]  
> 
> Small update for the list, after this discussion was moved to IRC:
> 
> The impetus for backcompat stems from demerphq's company having
> banned feature.pm outright, making a way to implement it without
> using feature seemingly the only way to achieve access to it at all.
> 
> However, as of 5.16, feature functions are also available in CORE::
> as per:
> 
> https://perldoc.pl/perl5160delta#The-CORE::-prefix
> 
> That means this works:
> 
> *x = *CORE::fc; x("AA");
> 
> That means both of these shim modules would work:
> 
> package Trim; BEGIN { *trim = ( $] >= $version ? *scalar::trim : sub { .... } ) };
> 
> package Trim; BEGIN { *trim = ( $] >= $version ? *CORE::trim   : sub { .... } ) };
> 
> Thus demerphq's feature requirement is fulfilled regardless of which
> implementation is chosen.
> 
> That leaves the issue that this needs to work:
> 
> use 5.777;
> say trim <>;
> 
> If the implementation is:
> CORE:: - the path is already clear
> scalar:: - some work is needed to figure out how to make it happen.

What if an end-user expects trim () to work on a list as chomp does?

  chomp (my @foo = <>);
  trim  (my @bar = <>);

(triggered by "say trim <>")

Whatever the outcome, don't count this question as pro or con. I am not
part of the target audience.

-- 
H.Merijn Brand  https://tux.nl   Perl Monger   http://amsterdam.pm.org/
using perl5.00307 .. 5.33        porting perl5 on HP-UX, AIX, and Linux
https://tux.nl/email.html http://qa.perl.org https://www.test-smoke.org
                           

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