Re: sequence and iterables

On 11/15/13 10:09 PM, Jonas Sicking wrote:
> Just having side effects isn't really enough, no? It needs to be also
> possible for the caller to synchronously run code after the side
> effects of the doStuff calls for some items have happened, but before
> the side effects of other doStuff calls have happened.

Sure, but the caller can do that on every next() call on the iterator, no?

> For example if doStuff(n) simply adds the value 'n' to some page
> accessible state, that is a side effect, but not enough of a side
> effect that the page can detect iterating vs. snapshotting.

It actually is, from inside the iterator's next() method.

> So you really need some form of callback as far as I can tell.

The iterator itself is the callback.

-Boris

Received on Saturday, 16 November 2013 12:50:50 UTC