1 # example program showing that 'return-continuation-until-mark' can 'pause' a 2 # function call, returning a continuation, and that calling the continuation 3 # can 'resume' the paused function call. 4 5 def main [ 6 local-scope 7 k:continuation <- call-with-continuation-mark create-yielder 8 { 9 ¦ x:num, done?:bool <- call k # should return 1 10 ¦ break-if done? 11 ¦ $print x 10/newline 12 ¦ loop 13 } 14 ] 15 16 def create-yielder -> n:num, done?:bool [ 17 local-scope 18 load-ingredients 19 n <- copy 0 20 return-continuation-until-mark 21 done?:bool <- greater-or-equal n, 3 22 n <- add n, 1 23 ]