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

Re: Revisiting trim

Thread Previous | Thread Next
From:
Scott Baker
Date:
May 27, 2021 16:36
Subject:
Re: Revisiting trim
Message ID:
38f5c668-ee3e-c51b-ac7b-e1c211887de1@perturb.org
On 5/26/21 1:20 PM, Neil Bowers wrote:
>
>   * We think we should add a single function to Perl.
>   * It should return the trimmed string.
>   * It should be called "trimmed", not "trim".
>
> This is not a mandate, but it is our recommendation.

As the original author of this I appreciate the clear and concise
response. Thank you PSC for continuing to meet and discuss these issues
and provide guidance.

Personally I'd prefer *trim()* instead of *trimmed()* just for
consistency with other languages:

  * PHP = trim() <https://www.php.net/manual/en/function.trim.php>
  * Javascript = trim()
    <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim>
  * Raku = trim() <https://docs.raku.org/routine/trim>
  * Go = trim()
    <https://www.geeksforgeeks.org/how-to-trim-a-string-in-golang/>
  * Vimscript = trim()
    <https://github.com/vim/vim/commit/295ac5ab5e840af6051bed5ec9d9acc3c73445de>
  * PowerShell = trim()
    <https://devblogs.microsoft.com/scripting/trim-your-strings-with-powershell/>
  * VBA = trim() <https://trumpexcel.com/vba-trim/>
  * C# = trim()
    <https://www.c-sharpcorner.com/uploadfile/mahesh/trim-string-in-C-Sharp/>
  * String::Util = trim()
    <https://metacpan.org/pod/String::Util#trim($string),-ltrim($string),-rtrim($string)>
  * Text::Trim = trim() <https://metacpan.org/pod/Text::Trim>
  * Lisp = string_trim() <http://clhs.lisp.se/Body/f_stg_tr.htm>
  * Python = strip()
    <https://www.journaldev.com/23625/python-trim-string-rstrip-lstrip-strip>
  * Ruby = strip()
    <https://ruby-doc.org/core-2.7.1/String.html#method-i-strip>

If we go with *trimmed()* we'll definitely be an outlier. Since the PSC
has agreed this is a valuable feature, and should be included in core
(bike shedding is done), the only thing left to debate before we have a
final implementation is the name.

I'd like to being work in earnest next Monday on this feature. Can we
debate the best name here for a couple days so I can begin work on the
final feature? I have a large rebase on the PR to do, and some other
tweaking.

- Scott


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