Created
August 4, 2011 08:16
-
-
Save folone/1124712 to your computer and use it in GitHub Desktop.
Scala continuations explanation. More on this there -> http://dcsobral.blogspot.com/2009/07/delimited-continuations-explained-in.html
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
reset { | |
// A | |
shift { cf: (Int=>Int) => | |
// B | |
val eleven = cf(10) | |
// E | |
println(eleven) | |
val oneHundredOne = cf(100) | |
// H | |
println(oneHundredOne) | |
oneHundredOne | |
} | |
// C execution continues here with the 10 as the context | |
// F execution continues here with 100 | |
+ 1 | |
// D 10.+(1) has been executed - 11 is returned from cf which gets assigned to eleven | |
// G 100.+(1) has been executed and 101 is returned and assigned to oneHundredOne | |
} | |
// I |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment