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:
Christian Walde
Date:
November 25, 2020 10:10
Subject:
Re: Looking for someone to adopt adding trim() to core
Message ID:
op.0umui6bkydyjqt@xenwide.vpn.udag.de
Thanks, and yep, that is the consideration. :)

trim is considered to be something used very often, and while not necessarily identical to say in use, tho in the same category.

To give some concrete numbers, this (quickly googled) blog post indicates trim is the #13 php function in many open source projects: https://www.exakat.io/en/top-100-php-functions/ , this one indicates it is also used very much in the php unit testing suite: https://thephp.website/en/issue/most-used-php-functions/

And looking at CPAN:

https://grep.metacpan.org/search?q=%5C%5E%5C%5Cs%5C%2B%5B%5E%5C0%5D%2B%5C%5Cs%5C%2B%5C%24%7C%5C%5Cs%5C%2B%5C%24%5B%5E%5C0%5D%2B%5C%5E%5C%5Cs%5C%2B&qd=&qft=

1050 distributions and 1659 files implement some kind of regex-based whitespace stripping, and while this function isn't aimed at CPAN, this demonstrates a clear desire.

For a (not at all equal, but related) comparison, searching for uses of say:

https://grep.metacpan.org/search?q=%5Cbsay%5B+%28%5D&qd=&qft=

results in 914 dists.

On Wed, 25 Nov 2020 05:57:48 +0100, Yuki Kimoto <kimoto.yuki@gmail.com> wrote:

>> say is also "just a function" and is extremely similar in many ways. To treat trim any different from say requires >extremely strong arguments to explain how it is different from say.
>
> First, I think it is necessary to discuss the frequency of use.
>
> Personally, I think say is used every time in almost every script.
>
> On the other hand, I think trim is used for specific purposes such as editing web input.
>
> Even if it's a function, if it's obvious that it's used quite often, the function might consider putting it in the main/>CORE namespace.
>
>
> 2020年11月19日(木) 8:03 Christian Walde <walde.christian@gmail.com>:
>> The point is to minimize the work a non-cpan developer has to do to have access to the function.
>>
>> Precisely because it's implementation is so small, in the range of the code needed for say, it must also be able >>to be used with minimum effort.
>>
>> The suggestions you have, of tracking dependencies beyond Perl version, would increase the work-to-use >>needed to a point where the entire undertaking is wholly pointless.
>>
>>
>> Also, to be frank, nothing you said actually adresses the email you replied to. At all.
>>
>>
>> say is also "just a function" and is extremely similar in many ways. To treat trim any different from say requires >>extremely strong arguments to explain how it is different from say.
>>
>>
>> On Wed, 18 Nov 2020 23:31:41 +0100, Yuki Kimoto <kimoto.yuki@gmail.com> wrote:
>>
>>> I think trim is just a function.
>>>
>>> The function means that it takes arguments and returns return value.
>>>
>>> I think the benefits of adding trim as a Perl grammar are small.
>>>
>>> I think it's a best idea to add trim to Scalar::Util.
>>>
>>> use Scalar::Util 'trim';
>>>
>>> trim $string;
>>>
>>> The reason is that there are a few changes and the benefits are great.
>>>
>>> I think The next best idea is to add a new namespace.
>>>
>>> use Scalar 'trim';
>>>
>>> trim $string;
>>>
>>> This adds a new namespace, or module, so the size of the changes will be a bit larger.
>>>
>>>
>>> 2020年11月19日(木) 5:20 Christian Walde <walde.christian@gmail.com>:
>>>> One more note:
>>>>
>>>> say is EXTREMELY similar to trim, and as far as i can tell was VERY well received and caused no significant >>>>issues. Right?
>>>>
>>>> --With regards,
>>>> Christian Walde
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