about summary refs log blame commit diff stats
path: root/continuation1.mu
blob: 47d036fa62c635694c7fe0d861923ffa2ba7d225 (plain) (tree)
1
2
3
4
5
6
7
8
9
                                                                             

                                                                            
 




                                              

                  



                                                              

                                    

 
                             

                  
                                
          
 
# Example program showing that 'return-continuation-until-mark' can 'pause' a
# function call, returning a continuation, and that calling the continuation
# can 'resume' the paused function call.
#
# To run:
#   $ git clone https://github.com/akkartik/mu
#   $ cd mu
#   $ ./mu continuation1.mu
#
# Expected output:
#   1

def main [
  local-scope
  k:continuation <- call-with-continuation-mark create-yielder
  x:num <- call k  # should return 1
  $print x 10/newline
]

def create-yielder -> n:num [
  local-scope
  load-ingredients
  return-continuation-until-mark
  return 1
]