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/mu1 6 # $ cd mu1 7 # $ git checkout 4a48bedcd1 # state as of this writing; later versions may be incompatible 8 # $ ./mu continuation3.mu 9 # 10 # Expected output: 11 # caller 0 12 # callee 0 13 # caller 1 14 # callee 1 15 # caller 2 16 # callee 2 17 18 def main [ 19 local-scope 20 $print [caller 0] 10/newline 21 k:continuation <- call-with-continuation-mark f 22 $print [caller 1] 10/newline 23 k <- call k 24 $print [caller 2] 10/newline 25 call k 26 ] 27 28 def f [ 29 local-scope 30 $print [callee 0] 10/newline 31 return-continuation-until-mark 32 $print [callee 1] 10/newline 33 return-continuation-until-mark 34 $print [callee 2] 10/newline 35 ]