Re: sequence and iterables

On Fri, Nov 15, 2013 at 6:13 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> I'm no longer entirely convinced that sequence should necessarily map to
> iterables.
>
> In particular, sequence as currently specced would correspond to
> snapshotting the iterable immediately, but that's an odd thing to do with an
> iterable.  A more natural representation of iterables might be some sort of
> iterator object, though then you have to be very careful about it throwing
> exceptions, etc...

Can you give an example of when this is a problem. Snapshotting an
iterable to me simply means iterating the iterator all the way through
and remembering the data that it returned.

This is generally something that we want to do synchronously from the
API before returning. Otherwise we need to defined exactly when the
iterator is read. I can't think of any existing APIs that deal with
array-like things and that doesn't iterate through the whole
array-like before returning.

/ Jonas

Received on Saturday, 16 November 2013 02:18:54 UTC