-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Make StringOps a pure value class #6565
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
Conversation
|
How can we be sure that we don’t forget operations? (like it was the case with |
|
Hmm... the change is not binary compatible and causes the partest binary to fail |
|
#6566 would fix that issue |
|
I went through the scaladoc generated from the previous implementation to make sure that I don't overlook any operations. AFAIR @lrytz linked to a tool to automate this in some ticket but I can't find it anymore. We still need to fix |
|
In https://github.com/scala/collection-strawman/issues/419 I proposed some crude code that uses reflection to show members |
lrytz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which are the "other collection-values methods with widening" that are "not very useful"? It would probably be good to deprecate them.
| * @return the first char of this string. | ||
| * @throws NoSuchElementException if the string is empty. | ||
| */ | ||
| def head: Char = if(s.isEmpty) throw new NoSuchElementException else s.charAt(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could also include a message "head of empty string"
|
All widening operations (excluding Standard collection operations that are overloaded in Useful because it allows widening to Widening doesn't make much sense here. We could remove the widening. These methods could be removed completely. You'll still be able to call the version in |
b9d20a1 to
e759e8e
Compare
|
Rebased and updated. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
e759e8e to
5e60987
Compare
|
Rebased on top of #6611 (and fixed some exception messages) |
da99b03 to
6d36d86
Compare
This is the same treatment we gave ArrayOps previously. Some of the more complex and nonsensical (for Strings) operations are provided for compatibility. They delegate to WrappedString. Most operations have efficient implementations in StringOps.
6d36d86 to
7c68757
Compare
This is the same treatment we gave ArrayOps previously. Some of the
more complex and nonsensical (for Strings) operations are provided for
compatibility. They delegate to WrappedString. Most operations have
efficient implementations in StringOps.
Fixes scala/bug#10845.
Fixes scala/bug#10844.
I've changed the signature of
containsto disallow widening (and thus the need for expensive equality tests):Other collection-values methods with widening (from Char to Any) are probably not very useful for Strings. We should consider deprecating them.
The following methods are new overloads. They were missing for completeness: