Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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();


I 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.


I mean you could refer to the function by its name, and then run it with () when ready.


Oh, 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.


Oh, that's a good point. Didn't consider that.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: