I was recently looking for missing strutils.removePrefix().

Easy to create of course.

strutils.removeSuffix() modifies the string in place, which makes much sense, 
as it only uses setlen().

But what should a removePrefix() do? The operation is more expensive, one has 
to create a new string and copy characters, or one has to move characters.

So should removePrefix() do modification in place or return a modified result? 
Should it report about success?

Use case:
    
    
    s.removePrefix("GTK_")
      if not s.removePrefix("GTK_"): echo "not a GTK symbol"
      var strippedString =   s.removePrefix("GTK_")
    

Ruby has used proc names terminated with ! for inplace operation. But Nim is 
not Ruby.

Should we have prefixRemoved() for modified results and removePrefix() for in 
place operation?

Reply via email to