On Monday, January 29, 2018 3:35:18 PM CST Michael Morris wrote:
> On Mon, Jan 29, 2018 at 3:26 PM, Rowan Collins <rowan.coll...@gmail.com>
> 
> wrote:
> > Nor are generators the only non-rewindable iterables you need to worry
> > about, so really the only options you have are to only inspect arrays, or
> > to add a big fat warning that the function may consume your iterable (or
> > enter an infinite loop).
> 
> Sorry about the double reply.  What about using count() as a guard?  While
> there might be some countable consumables, my understand of generators is
> they are often used where no prior count is available. Arrays and
> ArrayObjects are countable.

It's totally legit to have an object that is a consumable iterable that is 
also countable.  (So many -ables in that sentence...)

Really, these functions would be useful only on arrays, period.  To allow them 
on anything else is just dangerous, and on other iterables there are better, 
more robust approaches (as discussed elsewhere in this thread).

As you've demonstrated they're also quite compact and effective to do in user-
space, so unless there's a massive performance difference of moving them to C 
they don't seem all that appropriate to add to the language directly.

--Larry Garfield

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to