[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


This page is part of the web mail archives of SRFI 44 from before July 7th, 2015. The new archives for SRFI 44 contain all messages, not just those from before July 7th, 2015.

The iterator model is unclear to me.
First, the name "iterator" may not be the best choice.
When I use an "iterator" to iterate through a sequence,
in most languages I change the location of the iterator,
but the identity of the iterator object does not change.
In the proposed API, iterators themselvs are immutable,
and you move to a new position by getting a new iterator.
This is reasonable for a (mostly-)functional language
like Scheme, but perhaps "position" would be a better name?

The specification for iterator-value says it is an error to call
this function when the iterator is at the start *or* at
the end position.  If I have a sequence with N elements,
it has N+1 positions before, after, or between elements.
If iterator-value is an error for the two end positions,
that means there are only N-1 values you can access.  That is
obviously a problem.

My conclusion is the model is that there are N+2 iterators for
a sequence of N elements.  I guess this could be made to work,
but it is different from what I'd expect.  (Input ports follow
the N+1 model.)  I think there needs to be some motivation for
this model, and a little exploration of the consequences.

Btw: For Java collections, the "value" of am
iterator depends on whether you last moved forwards or backwards.
I.e. the number of states is (I believe) 2*N.  Not that I would
advocation such a model!

	--Per Bothner
per@xxxxxxxxxxx   http://per.bothner.com/