-
Notifications
You must be signed in to change notification settings - Fork 187
Strip and chomp #385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for bringing up the issue @sgeard. The Python also has a Personally, I'm also not a fan of the name The reason we can't use I believe one typical usage case of these functions (in Python at least) is line-based processing of a file. One will use strip to remove the trailing new-line character, and again to remove whitespace upon splitting the string into chunks. cc @zbeekman |
Thanks for moving this into an issue - I should have done that in the first place. I'd still prefer trimright, trimleft, trimboth as names. Fortran programmers know what trim does so these functions would behave as expected. In general I think we should have a design philosophy so that we get a cohesive whole. My suggestions would be to use an existing API like std::string from C++ or the string command from Tcl. As I said originally I've never needed a chomp function despite decades of writing cross-platform scripts that read and write text. That some languages seem to need it suggests a design deficiency in them which it would be nice not to replicate here. |
My own exposure to Tcl is limited to writing environment modules, so I can't comment on Tcl here. As for Fortran, the The implemented function |
That's a good point. The fact that One alternative might be to merge the behavior of |
I simply suggested trimright because trim already exists but it would make much more sense to use trim if possible. I understand what chomp is doing but I don't understand why it's ever useful. I'd have thought the use-case is so rare it would be better left to the regex parser. Adding functions to libraries always has downstream maintenance costs so there needs to be some justification for its inclusion. As @awvwgk says, record based i/o doesn't return newline characters and that's true in Fortran, C++, C# and Tcl. The only case I think it could be good to support is when the line itself contains non-printing characters such as with tab-separated files. For that we need a tokenizer like a split(string,set) function/method (which we might have already - I haven't looked). |
Split is currently discussed at #241. |
Octave has a function called FWIW, I find the name |
Two variations on the theme of getting rid of spaces, from the Fortran String Utilities by George Benthien:
|
@sgeard commented in #343 (comment):
The text was updated successfully, but these errors were encountered: