Hacker News new | past | comments | ask | show | jobs | submit login

Generators are implemented with continuations, just like C#'s iterators (yield return statement). In C#'s case, it rewrites the function into a continuation via a state machine, but it's just using an integer to point at the remainder of the function, just like an index into an array isn't very different to a pointer - it's a distinction without much of a difference.

(JS VMs are free to implement generators however they like, of course.)




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: