1 # Example program showing that a function call can be 'paused' multiple times,
 2 # creating different continuation values.
 3 #
 4 # To run:
 5 #   $ git clone https://github.com/akkartik/mu
 6 #   $ cd mu
 7 #   $ ./mu continuation3.mu
 8 #
 9 # Expected output:
10 #   caller 0
11 #   callee 0
12 #   caller 1
13 #   callee 1
14 #   caller 2
15 #   callee 2
16 
17 def main [
18   local-scope
19   $print [caller 0] 10/newline
20   k:continuation <- call-with-continuation-mark 100/mark, f
21   $print [caller 1] 10/newline
22   k <- call k
23   $print [caller 2] 10/newline
24   call k
25 ]
26 
27 def f [
28   local-scope
29   $print [callee 0] 10/newline
30   return-continuation-until-mark 100/mark
31   $print [callee 1] 10/newline
32   return-continuation-until-mark 100/mark
33   $print [callee 2] 10/newline
34 ]