Created
October 25, 2012 20:02
-
-
Save refractalize/3955063 to your computer and use it in GitHub Desktop.
Coroutines in Pogo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
last yield continuation = nil | |
last result continuation = nil | |
yield (n, yield continuation) = | |
last yield continuation = yield continuation | |
last result continuation (nil, n) | |
coroutine (block) = | |
run (result continuation) = | |
last result continuation = result continuation | |
if (last yield continuation) | |
last yield continuation () | |
else | |
block | |
last yield continuation = nil | |
last result continuation = nil | |
strings = coroutine | |
yield! 1 | |
yield! 2 | |
yield! 3 | |
console.log (strings!) | |
console.log (strings!) | |
console.log (strings!) | |
console.log 'finished' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment