mu/continuation1.mu

26 lines
596 B
Plaintext
Raw Normal View History

# 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.
#
2017-11-25 18:17:23 +00:00
# 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 100/mark, create-yielder
2017-11-17 07:39:46 +00:00
x:num <- call k # should return 1
$print x 10/newline
]
2017-11-17 07:39:46 +00:00
def create-yielder -> n:num [
local-scope
2017-12-04 07:25:40 +00:00
load-inputs
return-continuation-until-mark 100/mark
2017-11-17 07:39:46 +00:00
return 1
]