Adam Lally wrote:
On Wed, Mar 19, 2008 at 3:47 PM, Burn Lewis <[EMAIL PROTECTED]> wrote:
 Finally, I may be naive but I can see no technical objection to making the
 implementation of the CasIterator support a more forgiving and efficient
 interface to user code, especially since the code changes may be simpler
 than the documentation changes.

... and either would be simpler than having this discussion. ;)
My 2 cents: The world is complicated; documentation is often to big to read. Where we can, we should insure that our design, when it has features that match much more wide-spread designs our users would know about (i.e., the Java language), follow the semantics of the wide-spread designs that our users would know about.

So I would agree with Adam and Thilo that "hasNext()" should follow the Java "contract".

That's not to say, though, that we couldn't apply the patch to not call it extra times from the framework. I would vote to update the documentation to say something like hasNext() works like it does in normal java iterators (I'm assuming that's true :-) ), and then include a warning it might be called multiple times, although the framework will attempt to avoid doing that (for "efficiency" reasons), where feasible.

I just think it doesn't make sense for a method called hasNext to
advance the iterator.
+1.  This is consistent with Java's design here, I think.
Perhaps it's the very fact that I've learned
one must be vigilant about this when implementing an Iterator that
makes this so ingrained to me, so much so that I am objecting on
principle here.

I have to agree that there isn't any good reason why the framework
should actually call hasNext two times.
+1. It probably should avoid doing this for "efficiency" reasons, where feasible.

-Marshall

Reply via email to