about summary refs log tree commit diff stats
path: root/callcc.mu
blob: c9edfa47a0280da8932377cfc5e306ed7202c4a6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# example program: saving and reusing call-stacks or continuations

recipe main [
#?   $start-tracing #? 1
  c:continuation <- f
  continue-from c:continuation            # <-- ..when you hit this
]

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

recipe g [
  c:continuation <- current-continuation  # <-- loop back to here
  $print 1:literal
  reply c:continuation
]