Proposal: Hide the int in opApply from the user

Bill Baxter dnewsgroup at billbaxter.com
Wed Jan 9 15:54:51 PST 2008


bearophile wrote:
> Paul Findlay Wrote:
>> This is an old (1993), but I hope related, discussion:
>> Iterators: Signs of Weakness in Object-Oriented Languages
>> http://home.pipeline.com/~hbaker1/Iterator.html
> 
> Thank you for the link, it's quite interesting.
> From that article:
> 
>> The problem is that the "state" of the iterator must be stored somewhere, and the only two places are in the instance of the collection or the class of the collection. 
> 
> If you put a D opApply as a metod of a collection class, it allows you to enumerate the Cartesian product of a collection with itself too.

In other words, the author seems to have overlooked the other place 
where state can be stored: on the stack.

--bb



More information about the Digitalmars-d mailing list