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

Re: Revisiting trim

Thread Previous | Thread Next
Uri Guttman
May 26, 2021 20:55
Re: Revisiting trim
Message ID:
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.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About