Re: [PHP-DEV] Iterator Class/foreach Logic Flaw?

2004-03-08 Thread Marcus Boerger
Hello Andi, hello all Monday, March 1, 2004, 3:46:56 PM, you wrote: > As I said I'm indifferent. It would be nice to have Marcus in this > discussion but he's on the PHP Cruise and I'm not sure how often he's > checking is email. never. Today i am back and checked 1K8 mails :-( I'll change it

Re: [PHP-DEV] Iterator Class/foreach Logic Flaw?

2004-03-01 Thread Andi Gutmans
As I said I'm indifferent. It would be nice to have Marcus in this discussion but he's on the PHP Cruise and I'm not sure how often he's checking is email. At 09:21 AM 3/1/2004 -0500, Hans Lellelid wrote: Hi - Andi Gutmans wrote: Well we don't have very much time anymore because I want to roll

Re: [PHP-DEV] Iterator Class/foreach Logic Flaw?

2004-03-01 Thread Hans Lellelid
Hi - Andi Gutmans wrote: Well we don't have very much time anymore because I want to roll RC1 ASAP (assuming that we get a couple of bugs fixed which need fixing). Personally I'm fine with either of these (I don't mind hasMore()) but a decision has to be reached quickly. From discussing with Ma

Re: [PHP-DEV] Iterator Class/foreach Logic Flaw?

2004-03-01 Thread Andi Gutmans
Well we don't have very much time anymore because I want to roll RC1 ASAP (assuming that we get a couple of bugs fixed which need fixing). Personally I'm fine with either of these (I don't mind hasMore()) but a decision has to be reached quickly. From discussing with Marcus I don't think he feel

Re: [PHP-DEV] Iterator Class/foreach Logic Flaw?

2004-03-01 Thread Hans Lellelid
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?'.

[PHP-DEV] Iterator Class/foreach Logic Flaw?

2004-02-26 Thread Philip Fletcher
At the risk of making a complete fool of myself, I'd like to ask the smarter brains than me to checkout the current logic in the implementation of Iterator classes and foreach(). The current logic of foreach( $obj as $key => $val ) { ... } where $obj implements Iterator, is: for($obj->rewind(); $

Re: [PHP-DEV] Iterator Class/foreach Logic Flaw?

2004-02-26 Thread Marcus Boerger
Hello Philip, have a look at it's dokumentation: ext/spl/spl.php there you'll find that hasMore() needs to be checked before an access to key() or current() can be done. Hence it's meaning is somewhat like isValid(). regards marcus Thursday, February 26, 2004, 4:53:50 PM, you wrote: > At the ri

Re: [PHP-DEV] Iterator Class/foreach Logic Flaw?

2004-02-26 Thread Philip Fletcher
Thanks Marcus 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

Re: [PHP-DEV] Iterator Class/foreach Logic Flaw?

2004-02-26 Thread Andrei Zmievski
On Thu, 26 Feb 2004, Philip Fletcher wrote: > Thanks Marcus > > 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 m

Re: [PHP-DEV] Iterator Class/foreach Logic Flaw?

2004-02-26 Thread Philip Fletcher
Sorry for follow-up to myself, but it would be somewhat easier to just rename hasMore() to isValid() and then implement hasMore() after PHP5 goes gold. Philip Fletcher wrote: > Whilst I appreciate adding an isValid() method to the Iterator interface > is not trivial (and I am loath to suggest a c

Re: [PHP-DEV] Iterator Class/foreach Logic Flaw?

2004-02-26 Thread Marcus Boerger
Hello Philip, just to make it clear. hasMore() would be the exact same then isValid() only the name would change. The semantic is already what you refer to as isValid. Thursday, February 26, 2004, 9:43:40 PM, you wrote: > Sorry for follow-up to myself, but it would be somewhat easier to just > r

Re: [PHP-DEV] Iterator Class/foreach Logic Flaw?

2004-02-26 Thread Philip Fletcher
Hi Marcus Yes, the current implementation of hasMore() has an identical semantic to isValid(). The generally understood semantic of isValid() and hasMore() are quite different - hence the need for the rename. Regards Philip Marcus Boerger wrote: > Hello Philip, > > just to make it clear. has

Re: [PHP-DEV] Iterator Class/foreach Logic Flaw?

2004-02-26 Thread Marcus Boerger
Hello Philip, Thursday, February 26, 2004, 10:05:09 PM, you wrote: > Hi Marcus > Yes, the current implementation of hasMore() has an identical semantic to > isValid(). > The generally understood semantic of isValid() and hasMore() are quite > different - hence the need for the rename. As a sid

Re: [PHP-DEV] Iterator Class/foreach Logic Flaw

2004-02-26 Thread Philip Fletcher
Marcus Boerger wrote: > As a side note: There is no generally understood hasMore(). I strongly disagree - the Java Iterator has a hasNext() method which is the exact sementic of hasMore(). > Though there > is isDone() and hasMore() is sometimes used/implemented as !isDone(). The > main problem