Hi Steve > The more obvious way to implement the loop would be to put the body BEFORE > the 'next' statement, and at first I thought that maybe the manual has a > typo. But then I checked the file dict.jl, and I found indeed the code: > > done(t::ObjectIdDict, i) = is(next(t,i),()) > > So this means that every loop iteration over an ObjectIdDict requires two > calls to 'next', one as part of the call to 'done', and a second one to > actually advance the loop.
Presumably for ObjectIdDict calling next is cheap, so there is no reason to avoid one extra call. In particular as ObjectIdDict is coded in C, this avoids having to write more C code. > I also looked at the code for 'done' for Dict in dict.jl, and it appears to > be buggy(??). It does not check whether everything after the current i is > deleted(??) For `Dict` `done` does not call `next` again. Maybe you can model your iterator after that? Also, I think there is no bug in it, as `skip_deleted` will return the index of the last `d.vals` if there are no more filled slots, which in turn makes `done` true.