1) ... functions "express" mappings
2) Generators "express" sequences
3) Don't muddy the waters
If only!-(
In current ES6 design, functions are mixed with generators (probably
based on the notion that the generator function call is suspended, even
though, in reality, generator functions return generator objects that
can be prompted to return next results).
In current ES6 design, generators represent iterators, which are
ephemeral pointers into stateful sequences (calling next has a
side-effect; previous sequence pointers are invalidated, you need
to make copies manually).
waters are clearly muddy :-(
Claus
PS. my standard suggestion for water purification:
- have a syntax for generator blocks, not generator functions
do*{...}
equivalent to immediately applied generator function,
(function*(){...}())
- have side-effect-free iterators
- combine modular language features at will, eg:
x=>do*{ yield 1; yield 2 }
function(x) { return do*{ yield 1; yield 2 } }
- profit! (simpler, more modular semantics, better compositionality)
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss