Skip to content

Instantly share code, notes, and snippets.

@stormbrew
Created September 10, 2011 00:29
Show Gist options
  • Save stormbrew/1207704 to your computer and use it in GitHub Desktop.
Save stormbrew/1207704 to your computer and use it in GitHub Desktop.
Ridiculously contrived coroutine example for Channel9
var ho
var hi = () {
var cont = ho
var count = 0
while (count != 1000) {
"hi " + count.to_string_primitive -> $stdout
// send count + 1 to cont, save its return address in cont
count = (count + 1 -> cont : cont)
}
}
var ho = (&count) -> cont {
while (true) {
"ho " + count.to_string_primitive -> $stdout
// send count + 1 to cont, save its return address in cont
count = (count + 1 -> cont : cont)
}
}
hi()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment