Claus Reinke (2013-12-12T20:52:27.000Z)
domenic at domenicdenicola.com (2013-12-24T23:47:40.588Z)
> 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 :-( 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)
forbes at lindesay.co.uk (2013-12-21T09:35:12.461Z)
> 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)