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

Re: Revisiting trim

Thread Previous | Thread Next
From:
Uri Guttman
Date:
May 26, 2021 20:55
Subject:
Re: Revisiting trim
Message ID:
d6f45fb1-4189-6902-4b3a-703b352dccd1@stemsystems.com
On 5/26/21 4:20 PM, Neil Bowers wrote:
> As a reminder, after a lot of discussion, there was broad agreement 
> that we should add the capability for trimming a string, and we should 
> keep it simple: trim whitespace from both ends of the string, with no 
> parameterisation. Here "whitespace" means [:space:], so consistent 
> Unicode semantics, whatever the internal encoding of the string.
>
> What convinced us on the naming issue was an example from Tom 
> Christiansen of a large company that had a similar internal 
> discussion, and found that people were confused over how they expected 
> it to work, until they changed the name from "trim" to "trimmed". This 
> also fits in with one of Larry's original desires, that Perl be a 
> readable language. The function returns a trimmed version of its input:
>
> $x = trimmed $y; # "x is a trimmed version of y"
>
> We think that "trim" would have been the right name for editing in place:
>
> trim $x;
>
what about trimmed using context? in a void context it trims in place. 
in scalar (or non-void) it returns the trimmed string and leaves the 
input unchanged. only one new function and we use context everywhere so 
it is familiar.

uri


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