Front page | perl.perl5.porters |
Postings from May 2021
Re: Revisiting trim
From: Ben Bullock
May 27, 2021 21:54
Re: Revisiting trim
Message ID: CAN5Y6m8rL6koNFOGyuLLN_WbG2R6=B8GAj3FxuRAHeDAxgaWxA@mail.gmail.com
On Fri, 28 May 2021 at 01:36, Scott Baker <firstname.lastname@example.org> wrote:
> 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>
> - Raku = trim() <https://docs.raku.org/routine/trim>
> - Go = trim()
> There is strings.Trim but it is not equivalent. The equivalent to your
Perl proposal is strings.TrimSpace:
> - Vimscript = trim()
> - PowerShell = trim()
> - VBA = trim() <https://trumpexcel.com/vba-trim/>
> It's actually called Trim (with a capital letter) in VBA. There is also
LTrim and RTrim.
> - C# = trim()
> - String::Util = trim()
> - Text::Trim = trim() <https://metacpan.org/pod/Text::Trim>
> - Lisp = string_trim() <http://clhs.lisp.se/Body/f_stg_tr.htm>
Lisp doesn't usually use underscores to separate words and it doesn't use
final brackets for arguments to functions either so this cannot be right.
> - Python = strip()
> - Ruby = strip()
> This does scotch the argument that "trim" is the most familiar form for
othe programming languages.
> If we go with *trimmed()* we'll definitely be an outlier.
Perl is already an outlier, who else uses "next" and "last" instead of
"break" and "continue", or uses -> for members rather than .?
> 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.
To avoid over-lengthy discussions, in my opinion the person who does the
implementation should basically have the right to choose the name at the
experimental stage. Then, if the name causes a problem in practice, it can
be changed. But a lot of these discussions on this mailing list have
involved imaginary people with imagined problems.
> 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
The very best possible name for this function is "trim". Or whatever you
want to call it.