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


                                                                  
                     
                                                                   



                     
         



                                                                 
          
                                                              
 
# example program: saving and reusing call-stacks or continuations

recipe main [
  c:continuation <- f
  continue-from c                         # <-- ..when you hit this
]

recipe f [
  c:continuation <- g
  reply c
]

recipe g [
  c:continuation <- current-continuation  # <-- loop back to here
  $print 1
  reply c  # threaded through unmodified after first iteration
]