Skip to content

Instantly share code, notes, and snippets.

@refractalize
Created October 25, 2012 20:02
Show Gist options
  • Save refractalize/3955063 to your computer and use it in GitHub Desktop.
Save refractalize/3955063 to your computer and use it in GitHub Desktop.
Coroutines in Pogo
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