From: Jim Weirich Date: 2003-03-25T20:42:50+09:00 Subject: Re: Iterate over two lists in parallel On Tue, 2003-03-25 at 02:26, Hal E. Fulton wrote: > Sprry to reply to my own post, but another > small issue is that the generator always > returns nil after it exhausts the collection. > > But what if a collection contains nil values? > > I think I'd like an 'end?' method or something. > At worst, we could define a meta-nil value, but > I'm betting that's not necessary. Yeah, my tutorial glossed over that part. Having a standard for external iterators will really help them be more useful. I would suggest more? instead of end?. This allows you to write loops in terms of the positive rather than a negative test. I.e. while it.more? Python iterators throw an exception when they are done. This means you have one less method call to make in a loop. I'm uncomfortable with the exception, it seems to be premature optimization. However, if you do go that route, then I like Julian's use of catch/throw over an exception (exceptions in my mind indicate a failure). -- -- Jim Weirich jweirich@one.net http://w3.one.net/~jweirich --------------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)