El 23/02/2015 20:29, Brendan Eich bren...@mozilla.org escribió:
Benjamin (Inglor) Gruenbaum wrote:
Of course this example is contrived! It's the simplest example I could
think of. I do think it stands for every example of any iterator that takes
any input from `.send` or `.throw`. I have
Why not? The generator would switch on sent value, in a loop.
Well, let's say we have an iterator that does nothing once, returns what
was sent to it the first 5 times and then is done:
```js
function* gen(){
var res = yield;
for(var i = 0; i 5; i++){
res = yield res;
}
}
var iter =
Benjamin (Inglor) Gruenbaum wrote:
Of course this example is contrived! It's the simplest example I could
think of. I do think it stands for every example of any iterator that
takes any input from `.send` or `.throw`. I have plenty of other
contrived examples (implementing `fork` like this by
Of course this example is contrived! It's the simplest example I could
think of. I do think it stands for every example of any iterator that takes
any input from `.send` or `.throw`. I have plenty of other contrived
examples (implementing `fork` like this by using generators for coroutines
with
Salvador de la Puente González wrote:
Yep. This was already discussed in the topic I mentioned before. Just
to remember, the real problem with tee() is that the generators are
not actually independent as you can not .send() different information
to each one to make them diverge.
Why not?
On Mon, Feb 23, 2015 at 10:34 AM, Brendan Eich bren...@mozilla.org wrote:
Salvador de la Puente González wrote:
Yep. This was already discussed in the topic I mentioned before. Just to
remember, the real problem with tee() is that the generators are not
actually independent as you can not
Tab Atkins Jr. wrote:
(Not saying anything needs to be added right now. Just pointing out
the specifics, as it seemed you were talking past each other.)
Thanks, I was thinking beyond tee as a generic, which copies (requiring
a set-aside, could be a lot of memory). If the cliff leads to
Benjamin (Inglor) Gruenbaum wrote:
Why not? The generator would switch on sent value, in a loop.
Well, let's say we have an iterator that does nothing once, returns
what was sent to it the first 5 times and then is done:
```js
function* gen(){
var res = yield;
for(var i = 0; i 5; i++){
Hey Philip,
you can see
https://esdiscuss.org/topic/proposal-generator-clone-and-generator-goto for
more about this topic.
On Wed, Feb 18, 2015 at 2:02 PM, Philip Polkovnikov
polkovnikov...@gmail.com wrote:
- 1. Where is the function `run`?
The function `run` is pretty classic variation on
As the comments from Tab Atkins and John Lenz there suggest, this is
best done above the level of the standard, for now. If we need to roll
up itertools including tee in ES7 (I am pretty sure we do), the best way
to get there is via github -- not by prematurely standardizing APIs or
Yep. This was already discussed in the topic I mentioned before. Just to
remember, the real problem with tee() is that the generators are not
actually independent as you can not .send() different information to each
one to make them diverge.
So producing a real clone of the generator is not
1. Where is the function `run`?
The function `run` is pretty classic variation on the code you would see in
`Q` or `bluebird`.
function run(gen) {
return function (/* args */) {
var args = Array.prototype.slice.call(arguments);
var iter = gen.apply(args);
(function step(arr) {
- 1. Where is the function `run`?
The function `run` is pretty classic variation on the code you would see in
`Q` or `bluebird`.
function run(gen) {
return function (/* args */) {
var args = Array.prototype.slice.call(arguments);
var iter = gen.apply(args);
(function step(arr) {
For the record, I proposed this feature before, and it wasn't seen as a good
idea, for some reason:
https://esdiscuss.org/topic/function-is-not-mandatory#content-47
Given how close ES6 is to ship, I think it's too late to make such changes to
the spec, we will have to live with it. Use Traceur
As pretty everyone already seen, generators are usually used in composition
with promises to yield (pun intended) a plain simple linear code. This
solution looks very much like monads from Haskell, yet in a better syntax:
every a - b in Haskell is a = yield b in JS, and that aids to get rid of
15 matches
Mail list logo