-
-
Notifications
You must be signed in to change notification settings - Fork 416
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
Why String.split uses the delim input as set of chars instead of Regex pattern or string delim? #1399
Comments
I haven't looked at this in detail yet, but it's possible we might want to consider this as a "principle of least surprise bug". I'm adding the "needs discussion during sync" label so we can discuss it at the next public weekly meeting. |
When this came up on IRC, I was very surprised. I consider this a bug. |
Discussed on sync. This is a "principle of least surprise bug". |
@enigma do you want to take this on? If yes, I can add you as a read only contributor so you can be assigned to the issue. |
@SeanTAllen yes please! |
O wow. we can assign people who aren't team members now @jemc ? |
@SeanTAllen - I assumed you had already added him. But now that you mention it, I think maybe you can assign someone who is already participating in the ticket (or maybe the requirement is that they filed the ticket?). |
@jemc that's a pretty cool change. i don't think it used to be that way. |
@enigma shall i mark this as in progress? |
@SeanTAllen Yes please. I don't think I can change any label. |
This is to fix ponylang#1399.
Hi @enigma, Any progress? Need any assistance? |
I'm unassigned @enigma and setting this back to ready for work. |
Isn't the functionality requested here exactly what |
I didn't notice this was still open, my bad! This should have been closed by f566596 - unless we want |
Eg:
prints:
alternative_split
is still not that great now as one has to escape regex special symbols. Also usingRegex
involves a lot of partial methods.Given
String.split
takes a string I'd expect a behaviour more similar to what Python does:My understanding is that this doesn't matter for the default argument behaviour, ie split by whitespacy symbols.
Could the signature of split be:
I think that could keep the default behaviour and make the specified one a bit less surprising (even though it's documented).
Also because of the influence Python had on me I think a common use case that might deserve to be the default is more similar to
Regex("[\s\t\v\f\r\n]+").split
. What do you think?The text was updated successfully, but these errors were encountered: