-
Notifications
You must be signed in to change notification settings - Fork 246
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
Compatibility with new iteration protocol #382
Compatibility with new iteration protocol #382
Conversation
The ambiguity check detects an ambiguity between Primes and Base, which is irrelevant for DataStructures.
Codecov Report
@@ Coverage Diff @@
## master #382 +/- ##
==========================================
- Coverage 96.58% 96.49% -0.09%
==========================================
Files 31 31
Lines 2312 2314 +2
==========================================
Hits 2233 2233
- Misses 79 81 +2
Continue to review full report at Codecov.
|
Could someone post a link to the "new iteration protocol"? I don't know about this, and I'd like to check that the sorted-container iterators are ok. |
https://docs.julialang.org/en/latest/manual/interfaces/#man-interface-iteration-1 But there is a relatively good compatibility layer; the only downside to it is that it defines a The only thing not due to ambiguity resolution (and what got me working on this) is 5ea4fcc: -done(t::OrderedDict, i::Int) = done(t.keys, i)
+done(t::OrderedDict, i::Int) = i > length(t.keys) Note that julia> done([1,2,3], 3)
false
julia> done([1,2,3], 4)
true But fails on current master: julia> done([1,2,3], 3)
ERROR: MethodError: no method matching done(::Array{Int64,1}, ::Int64) because the expected state is not an julia> start([1,2,3])
Base.LegacyIterationCompat{Array{Int64,1},Int64,Int64}(false, 1, 2) But actually, using |
That said, it might be a good idea to start using the new iteration protocol directly here. I just wanted to make it working and pass its tests quickly. |
Thanks! So if I put the new iteration protocol in code and precede it with |
There is no Compat support at the moment and I'd imagine it to be quite complicated to do, so I wouldn't expect it anytime soon (if at all). |
|
An alternative to the Meanwhile, can you give this a go? Or at least 5ea4fcc, which I could separate out if preferred, so that |
I had not previously looked at the code for OrderDict.jl, and now that I see it for the first time, I am concerned about its ongoing maintainability. It appears that someone started from the code for Dict and made modifications in various places. The problem with this is that Dict is very complicated code and uses low-level Julia interfaces. In fact, two bugs have been found in Dict just in the past year. So, really, the only people qualified to maintain this code for OrderedDict would be the maintainers of Dict, but I'm not sure if they are interested. A maintainable alternative would be to reimplement OrderedDict from scratch using existing Base data structures. For example, |
I agree with your assessment of the While this may not be the right place to discuss what a possible future |
It would be really great if this could get merged, currently this package is basically unusable on 0.7 due to this issue. |
In #386 I have replaced OrderedDict with a completely new implementation (described in my comment earlier in this thread). This should be mergeable with 0.7. This new implementation is less performant than the old implementation, so if this PR is accepted, I will open issues on github on recovering some of the lost performance (to be done later). |
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.
Tested locally. LGTM.
This makes DataStructures functional in face of the new iteration protocol and resolves all the occurring ambiguities.