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.
First, let me clarify that I am on record arguing for even shallower
continuations. I restated this preference in this very thread
https://mail.mozilla.org/pipermail/es-discuss/2013-July/031967.html
(scroll down to FYI)
I have no idea why both you and Brendan assert that I was arguing/
rehashing for deep delimited continuations (let alone call/cc). But as
this makes two of you, I've extracted my suggestions/questions to a
separate thread, where they are less likely to be lost/misread.
Second, my worries are about generators, because they introduce
a special built-in form that interferes with functional abstraction.
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.
My point is about expressiveness in the composition/abstraction/
refactoring/extract reusable components sense, not in the Turing
sense. Also,
zip = (a,b)=>a.reduce(function(x,y,i){return x.concat([[y,b[i]]])},[])
- 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.
Since I was merely trying to re-implement parts of "for-of" in user
land, I don't see how that could be the case.
Claus
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss