about summary refs log tree commit diff stats
path: root/continuation3.mu
blob: cde6095898491b6e5d5220c88b1c99f0493d8815 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Example program showing that a function call can be 'paused' multiple times,
# creating different continuation values.
#
# To run:
#   $ git clone https://github.com/akkartik/mu
#   $ cd mu
#   $ ./mu continuation3.mu
#
# Expected output:
#   caller 0
#   callee 0
#   caller 1
#   callee 1
#   caller 2
#   callee 2

def main [
  local-scope
  $print [caller 0] 10/newline
  k:continuation <- call-with-continuation-mark 100/mark, f
  $print [caller 1] 10/newline
  k <- call k
  $print [caller 2] 10/newline
  call k
]

def f [
  local-scope
  $print [callee 0] 10/newline
  return-continuation-until-mark 100/mark
  $print [callee 1] 10/newline
  return-continuation-until-mark 100/mark
  $print [callee 2] 10/newline
]
"p">( "time" "framagit.org/andinus/cetus/pkg/cetus" ) // GetBpodJson returns json response received from the api func GetBpodJson(reqInfo map[string]string, t time.Duration) (string, error) { params := make(map[string]string) params["format"] = "js" params["n"] = "1" // if random is true then fetch 7 photos if reqInfo["random"] == "true" { params["n"] = "7" } body, err := cetus.GetRes(reqInfo["api"], params, t) return string(body), err }