-
-
Notifications
You must be signed in to change notification settings - Fork 117
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 iterate (from next) #603
Comments
I guess the following should do it?
|
Hm. Actually. Maybe that's too simple. At least when I use that version on a
Trying to call
So, in case there's other code out thare relying on this
|
I guess that could be simplified to the more intuitive
|
Is anyone adding this Compat then? moving some (private for now) package 0.6 -> 1.0 , I've implemented some icky logic around this for now ... |
Note: the missing functionality - is future compatibility for maintaining 0.6 code working after re-writing the code with the newer 'iterate()' interface. |
I've ended up with a semi-generic code: mutable struct It
# what-ever-was there before, plus:
tmp_state # remove when 0.6 compat isn't needed anymore
end
iterate_(it, state) = # 1.0 style impl
iterate_(it) = # 1.0 style impl
if VERSION >= VersionNumber(0,7)
Base.iterate(it::It) = iterate_(it)
Base.iterate(it::It, state) = iterate_(it, state)
else # VERSION 0.6
function Base.start(it::It)
it.tmp_state = iterate_(it)
_, state = it.tmp_state
return state
end
Base.done(it::It, state) = nothing == it.tmp_state
function Base.next(it::It, state)
prev = it.tmp_state
it.tmp_state = iterate_(it, state)
return prev
end
end # VERSION 0.6 |
Closing as outdated since we've dropped support for Julia prior to 1.0. |
in 0.6 + Compat
after following
in 0.7
The text was updated successfully, but these errors were encountered: