On Sun 23 Nov 2014 12:54, Alex Kocharin a...@kocharin.ru writes:
Hmm... Interestingly, in Chrome if you do call it with 'new', 'this'
would refer to a generator itself. But not in FireFox. I'm playing
around with this example:
```
function *G() {
console.log(this === x)
yield 1
23.11.2014, 07:03, "Brendan Eich" bren...@mozilla.org:Axel Rauschmayer wrote: As an aside, I still feel that two concerns are mixed in a generator function: * The creation of the generator object. This is where the generator function is like a constructor and where you’d expect `this` to refer
Thanks all. My intent wasn't to propose that something was necessary,
just to ask if something was available that I was missing. I'll dig in
on the await spec and take a good look at the various examples everyone
provided.
Thanks!
___
es-discuss
After playing around with generators for most of the day (and pretty
much loving all of it), I ended up with a code example for async that
looks like this:
```
var fs = require(fs);
var task;
function readConfigFile() {
fs.readFile(config.json, function(err, contents) {
if (err)
It just goes to show how good promises are for this kind of problem. I’d
probably promisify `readFile` and use `Q.spawn()`.
The best I could come up with for Node.js-style callbacks was the following
code.
```js
var fs = require(fs);
function *init() {
var nextFunc = yield;
var
Hi Nicholas!
I can't go into more detail at the moment, but you might want to check out
task.js (http://taskjs.org/) and the async function proposal for ES7 (
https://github.com/lukehoban/ecmascript-asyncawait).
___
es-discuss mailing list
As an aside, I still feel that two concerns are mixed in a generator function:
* The creation of the generator object. This is where the generator function is
like a constructor and where you’d expect `this` to refer to the generator
object.
* The behavior. This is where the generator function
Axel Rauschmayer wrote:
As an aside, I still feel that two concerns are mixed in a generator
function:
* The creation of the generator object. This is where the generator
function is like a constructor and where you’d expect `this` to refer
to the generator object.
Nope, not a constructor
* The creation of the generator object. This is where the generator function
is like a constructor and where you’d expect `this` to refer to the
generator object.
Nope, not a constructor (and if you don't call with 'new', what is 'this',
pray tell?).
I only mean it is “like a
On Sat, Nov 22, 2014 at 8:03 PM, Brendan Eich bren...@mozilla.org wrote:
Axel Rauschmayer wrote:
A result of this mixing of concerns is that using `next()` to start a
generator feels slightly off and that the argument of that first `next()`
invocation is completely ignored.
We've
10 matches
Mail list logo