-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
SeqMap.keys is key iteration order only #10766
base: 2.13.x
Are you sure you want to change the base?
Conversation
I think either Doing something in between can probably avoid some surprises but not really prevent bugs. |
Not sure if lrytz agreed to undeprecate, so I pushed it as a separate commit, unsquashed. Sorry, Jenkins. To be clear, this PR was motivated by Ichoran's endorsement on the ticket, that even if
I can report that I do not feel wiser. |
I see the point that returning a Seq doesn't hurt and can prevent surprises. But if we don't actually guarantee anything then the value is very limited, surprises when using I think either |
This is only for SeqMaps that don't yet override. It could be restricted further to SeqMap1..4, to be more conservative. Then we can sort whether it's useful API etc under SIP-51. Otherwise, I'll have to at-notify Ichoran. |
67027de
to
bff3d35
Compare
it's not clear what the API intends:
|
@som-snytt where does this stand, in your opinion? also interested in @scala/collections opinions |
This standard is too high for me. |
I'm pretty sure I've mentioned this before somewhere, but I'd personally prefer that I would also like |
I don't remember why I reopened, but probably because Seth said
which is nerd-sniping as moral imperative. I'll refresh my memory and the branch. |
I see the trouble began with this spurious override in
The override would make sense on grounds of efficiency, but per the docs, anyone who wants this behavior should write it out. Lukas's comment is that the doc for If keys are ordered,
Addtionally, It is a non-goal of this PR to guarantee that As an example, The only reason to prefer I see the ticket is about checking equality. That is an especially weak expectation. Rex suggests the solution in this PR, just make When I touch the code, perhaps my perspective will change, and I'll note that here. |
bff3d35
to
f580d8d
Compare
The Ichoranism on scala/bug#12808
|
That is just java.io.IOException: No space left on device This PR will be squashable: it reverts the deprecated overriding, adds clarifying doc, and also slips in the Ichoranist "make it work" because why not. That calls for a mima exception for the private object, which I did not drill into during this expedition. |
f580d8d
to
87815f5
Compare
87815f5
to
2b71cd0
Compare
Note to self: I ran |
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.
If we're keeping all 3 methods around I'd like the docs to say when to use which - I don't know at this point.
Is there a big risk that existing custom maps would violate the new iteration order guarantee?
@@ -130,6 +132,7 @@ object SeqMap extends MapFactory[SeqMap] { | |||
f(key1, value1) | |||
f(key2, value2) | |||
} | |||
override def keys: Iterable[K] = Vector(key1, key2) |
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.
iiuc these overrides wouldn't be needed to support the new iteration order guarantee?
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.
Yes, that is only for the unreasonable expectation that a.keys == b.keys
for a couple of SeqMap
.
Undeprecate overriding Map keys
2b71cd0
to
6511259
Compare
I gave it some thought again, because what else are the winter holidays for, and I wavered a moment about whether to keep the deprecation of There is no justification for The clever pattern is that It occurs to me that |
assertSameElements(keys.iterator, sm.keys.iterator) | ||
assertSameElements(vm.keys, sm.keys) | ||
assertEquals(vm.keys, sm.keys) | ||
assertEquals(lm.keys, sm.keys) |
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.
final edit added the unreasonable expectation back in. Previously, keys
changed from Set
to Seq
after four elements. "But that's a change of only one letter!"
Fixes scala/bug#12991
Ensure that
keys
of aSeqMap
isain expected order.Seq
That satisfies the unwritten expectation that
keys
is orderedand mutually comparable.