about summary refs log blame commit diff stats
path: root/archive/0.vm.arc/callcc.mu
blob: 20dffeff15f338a67d92d7bce8a82d6bd1811a2d (plain) (tree)
1
2
3
4
5
6
7
8






                                                                              
                                                        











                                                                     
; in mu, call-cc (http://en.wikipedia.org/wiki/Call-with-current-continuation)
; is constructed out of a combination of two primitives:
;   'current-continuation', which returns a continuation, and
;   'continue-from', which takes a continuation to

(function g [
  (c:continuation <- current-continuation)  ; <-- loop back to here
  (print-character nil:literal/terminal ((#\a literal)))
  (reply c:continuation)
])

(function f [
  (c:continuation <- g)
  (reply c:continuation)
])

(function main [
  (c:continuation <- f)
  (continue-from c:continuation)            ; <-- ..when you hit this
])