//The first example of usning First-Class Continuation ... void saySomething() { standardOutput <- print("Hello ") @ standardOutput <- print("World ") @ currentContinuation; } .... //statement 1 in some method. saySomething() @ standardOutput <- print("SALSA"); |
// The second example - without First-Class Continuation // statement 2 may produce a different result from // that of statement 1. ... void saySomething() { standardOutput <- print("Hello ") @ standardOutput <- print("World "); } .... //statement 2 inside some method: saySomething() @ standardOutput <- print("SALSA") ; |
// The third example - with First-Class Continuation // One should see "Hello World" in the standard output // after statement 3 is totally executed. ... void saySomething() { boolean alwaysTrue=true; if (alwaysTrue) { standardOutput <- print("Hello ") @ standardOutput <- print("World ") @ currentContinuation; } standardOutput<-println("SALSA"); } .... //statement 3 inside some method: saySomething() @ standardOutput <- println() ; |