Hi Marcus,

Andrei Zmievski wrote:
On Thu, 26 Feb 2004, Philip Fletcher wrote:

Looking at the documentation, the comments and method name (for hasMore())
do not have the same meaning - the comment is saying 'does the current
element exist?' and the method name says 'are there any more elements?'.

This makes the api very ambiguous - hasMore() and isValid() have very
specific meaning in many languages wrt iterators.


I agree. The semantics are fairly different. Let's not confuse them.


I also agree strongly with the need for this to get fixed before PHP goes to release. IMO the current hasMore() is very misleading and has the result that people can't intuitively use it outside of the foreach() context.


Whether the method is called isValid() or something else that makes sense is less important to me, but providing an intuitive interface that won't leave code users scratching their heads or submitting bug reports for what appears to be faulty implementing iterator logic is really important.

BTW, Iterators are awesome(!), and it's only because they are so awesome & everyone will use them that I think this is important to address before release.

Thanks,
Hans

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to