develooper Front page | perl.perl5.porters | Postings from November 2020

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

Thread Previous | Thread Next
From:
demerphq
Date:
November 11, 2020 17:48
Subject:
Re: Looking for someone to adopt adding trim() to core
Message ID:
CANgJU+W9ZhR7QwS5wws9dLsqO9J5u1ZA2=k8XwkXa5UTGN7H4g@mail.gmail.com
On Wed, 11 Nov 2020 at 18:32, Corwin Brust <corwin@bru.st> wrote:
>
> Hi!  Long-time listener, first-time caller.
>
> On Wed, Nov 11, 2020 at 10:34 AM Konovalov, Vadim
> <Vadim.Konovalov@dell.com> wrote:
> >
> > Absolutely agree.
> > Please add my voice to the pool, and count it carefully.
> >
> > -----Original Message-----
> > From: demerphq
> > Sent: Wednesday, November 11, 2020 6:02 PM
> > To: Scott Baker
> > Cc: Perl5 Porters
> > Subject: Re: Looking for someone to adopt adding trim() to core
> >
> > Why does it need to be added to the language as a new keyword? You
> > could add it via universal.c to the SCALAR namespace (for example) and
> > have it accessible without any feature horribleness. I believe we have
>
> Can you please elucidate "feature horribleness"?  I'm wondering about
> specific down-sides you see.

Features like a new keyword change how perl parse's code and they
depend on your perl supporting the feature. There isnt a good way to
back port things that are exposed via feature.

Things that are exposed as normal functions in a namespace are
trivially back portable:

package Backport::Scalar::Trim;
BEGIN {
   if ($] < "5.30.5") {
       *Scalar::trim= sub { };
    }
}
*trim= *Scalar::trim;
use Exporter qw(import);
our @EXPORT_OK=qw(trim);
1;
__END__

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

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