Skip to content
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

delete! in sorted containers incompatible with Dict and Set #387

Closed
StephenVavasis opened this issue May 25, 2018 · 3 comments · Fixed by #607
Closed

delete! in sorted containers incompatible with Dict and Set #387

StephenVavasis opened this issue May 25, 2018 · 3 comments · Fixed by #607
Milestone

Comments

@StephenVavasis
Copy link
Contributor

The statement delete!(d,k), where d is a Dict or Set and k is a key, does not throw a key error even when k is missing from d. (In this case, it is a no-op.) On the other hand, SortedSet and SortedDict, throw a key error in this circumstance. Because these packages have been around for awhile, possibly someone is counting on this incompatible behavior, so I don't know whether to modify these containers to bring them in line with Dict. One subtlety: Dict and Set are not necessarily typed, whereas SortedDict and SortedSet are almost always typed. So one corner case is delete!(s,k) where s has keytype K, and k is not convertible to K.

@oxinabox
Copy link
Member

oxinabox commented Mar 4, 2020

From: #571 (comment)

Notice that there is an inconsistency with delete! that I didn't fix because I was afraid it would be a breaking change: #387

It is the general concensus that
turning errors into non-errors is not a breaking change.

@oxinabox oxinabox added this to the 1.0 milestone Apr 19, 2020
@NHDaly
Copy link
Contributor

NHDaly commented Apr 19, 2020

One subtlety: Dict and Set are not necessarily typed, whereas SortedDict and SortedSet are almost always typed. So one corner case is delete!(s,k) where s has keytype K, and k is not convertible to K.

I would agree that this "strongly typed" key functions is a feature of SortedDict/SortedSet, and so I think we can keep this behavior while still claiming to implement Base.AbstractDict / AbstractSet. It seems reasonable to me to allow delete! nonexistent keys only when they're a subtype of K. 👍

@NHDaly
Copy link
Contributor

NHDaly commented Apr 19, 2020

Okay, i've opened #607, which does exactly this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants