Hi Claus,

On Wed 24 Jul 2013 22:07, "Claus Reinke" <[email protected]> writes:

> 2 generators do not compose as freely as iteration functions,
>    because they are tied to special syntax and restricted contexts

You place blame on generators here, but beside the laments about deep
coroutines -- totally understandable, but Brendan is right that that
they are pointless -- your examples apply just as well to iterators of
all kinds.  It just happens that generators are a convienient way to
implement iterators.

Your point sounds like "external iteration does not compose as freely as
internal iteration" -- which is strictly not true!  You can't implement
zip, for example, with internal iteration, whereas you can with external
iteration.

> - if you compare the versions that use "for-of" with those (ending  with
> a "_") that use a user-defined abstraction "forofG", you'll see  a lot
> of syntax noise, even worse than with the old long-hand  "function" - in
> terms of making functional abstraction readable,  this is going in the
> wrong direction, opposite to arrow functions.

I humbly suggest that these abstractions are simply in the wrong place.
The defining characteristic of an external iterator is that the consumer
is external to the producer.  Trying to push the consumer inside is
going to lead to contorted code, as you have seen.

> - I haven't yet figured out how to end an outer generator early
>    from within a "yield*" nested one (as needed for "take_"), without
> replacing "yield*" with a micro-interpreter.  That might just be
>    my incomplete reading of the draft spec, though?

"I haven't yet figured out how to end an outer function early from
within a nested function call, without replacing the call site with a
micro-interpreter."

:)

Cheers,

Andy
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to