-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add/collection strawman #1160
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
Add/collection strawman #1160
Conversation
Centered around views instead of iterators.
} | ||
|
||
/** Iterator defined in terms of indexing a range */ | ||
trait RandomAccessView[+A] extends View[A] { |
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.
AFAIK Rust initially had RandomAccessIterator
, but then they decided to drop it. It was creating more problems than solving.
It worked more or less by accident before. Now it's more complicated, but we also have tests.
Looked a bit more through the strawman
|
The only diffence between view and iterator lies in fact that views can be traversed several times.
Ie: view is just a producer of iterators |
Ah, thanks - so the by-name here is crucial:
|
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.
Implementing this in 2.12.0-RC1 broke existing code: https://issues.scala-lang.org/browse/SI-9943. It had a pretty weird overload where one parameter list was implicit and the other wasn't. We could ad-hoc exclude those cases, as the programmer probably doesn't think of them as overloaded, but that seems pretty, well, ad-hoc.
Alternatively, demand that all parameter types are the same. That's what dotty does currently. It compiles the code in SI-9943 OK. |
Yep, this is the main aspect where Scala 2's implementation differs. It seemed more regular to me to just |
Interestingly, this turned out to be a different problem: we admitted sealed classes (like <:<) as SAM types. Closing that hole made the type checker happy. |
Two additiions:
idioms for
map
onString
. Previously, this required an explicit type annotation.