Philip Polkovnikov (2015-02-18T13:00:35.000Z)
> 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) {
arr.forEach(function (item) {
iter.copy().next(item);
});
})(iter.next());
};
}

Probably, it would be nice to work out `return` there, so that this could
be a full-fledged nondeterminism monad, but everything should be already
clear.

> 2. I am against copying a generator instance. It's just like cloning a
context, with many difficulties and ambiguity. Shall we deep-clone or not?
How to efficiently implement such a method? I don't see useful cases in
which we need to clone a generator instance.

Regarding the availability of `.copy()` you can read in the description of
one Python package I've just found:

http://www.fiber-space.de/generator_tools/doc/generator_tools.html

> 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 to generate
state machines from your "yield functions" and use that as a basis in your
code.

The `copy` is worth the problems of frame copying. Anyway, I understand
that ES6 won't have `copy` as standard is just to be released, but it
should be added to JS once.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150218/1d136f01/attachment.html>
polkovnikov.ph at gmail.com (2015-02-18T13:07:23.929Z)
> 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) {
				arr.forEach(function (item) {
					iter.copy().next(item);
				});
			})(iter.next());
		};
	}

Probably, it would be nice to work out `return` there, so that this could
be a full-fledged nondeterminism monad, but everything should be already
clear.

> 2. I am against copying a generator instance. It's just like cloning a context, with many difficulties and ambiguity. Shall we deep-clone or not? How to efficiently implement such a method? I don't see useful cases in which we need to clone a generator instance.

Regarding the availability of `.copy()` you can read in the description of
one Python package I've just found:

http://www.fiber-space.de/generator_tools/doc/generator_tools.html

> 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 to generate state machines from your "yield functions" and use that as a basis in your code.

The `copy` is worth the problems of frame copying. Anyway, I understand
that ES6 won't have `copy` as standard is just to be released, but it
should be added to JS once.
polkovnikov.ph at gmail.com (2015-02-18T13:03:36.463Z)
> 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) {
				arr.forEach(function (item) {
					iter.copy().next(item);
				});
			})(iter.next());
		};
	}

Probably, it would be nice to work out `return` there, so that this could
be a full-fledged nondeterminism monad, but everything should be already
clear.

> 2. I am against copying a generator instance. It's just like cloning a

context, with many difficulties and ambiguity. Shall we deep-clone or not?
How to efficiently implement such a method? I don't see useful cases in
which we need to clone a generator instance.

Regarding the availability of `.copy()` you can read in the description of
one Python package I've just found:

http://www.fiber-space.de/generator_tools/doc/generator_tools.html

> 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 to generate
state machines from your "yield functions" and use that as a basis in your
code.

The `copy` is worth the problems of frame copying. Anyway, I understand
that ES6 won't have `copy` as standard is just to be released, but it
should be added to JS once.