3 ms·
Why didn't they simplify it (and make it more like current JS) by leaving out the .send() method? Wouldn't this make more sense? var tester = test; test
by firefoxman1 14y ago
Why didn't they simplify it (and make it more like current JS) by leaving out the .send() method?
Wouldn't this make more sense?
var tester = test;
tester();
- kilovoltaire 14y agoI assume you mean: var tester = test(); tester(); And yeah I agree, straight functions seem way nicer, which is what the coroutine() wrapper in the writeup ends up accomplishing. Javascript 1.7 copied the generator/coroutine objects straight from Python, and it's a weird fit... One thing that you can't do with just a function is have the .close() method, which may or may not be a fundamental issue.
- firefoxman1 14y agoI mean you could refer to the function by its name, and then run it with () when ready.
- kilovoltaire 14y agoOh, so you really did mean `var tester = test;` The reason that might be less good than the current approaches is that you may want to spawn multiple 'instances' of the generator/coroutine. If I'm understanding your proposal correctly, you'd only ever be able to run it once.
- firefoxman1 14y agoOh, that's a good point. Didn't consider that.