Created
September 10, 2011 00:29
-
-
Save stormbrew/1207704 to your computer and use it in GitHub Desktop.
Ridiculously contrived coroutine example for Channel9
This file contains 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
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