Nice explanation of using a trampoline with generators

I know what a trampoline is, but I have never bothered to really sit down and think about how the mechanism works, let alone an implementation. But this Lambda the Ultimate post on threads in JavaScript (which Brendan Eich says is not going to happen) links to another blog that shows how a trampoline, generators (as introduced in JS 1.7 and copied from Python), and 4K of JS code can get you lightweight threads, sort of.

It's one of the clearer explanations of how to use a trampoline with generators that I have read. Basically you are using generators and a stack to act like function calls and an execution frame, respectively. Think of it as very explicit continuations.

Seems like it would be a nicer way of doing multitasking compared to threading if you were not worrying about data access.