1 # Example program showing exceptions built out of delimited continuations. 2 3 # Since Mu is statically typed, we can't build an all-purpose higher-order 4 # function called 'try'; it wouldn't know how many arguments the function 5 # passed to it needs to take, what their types are, etc. Instead, until Mu 6 # gets macros we'll directly use the continuation primitives. 7 8 def main [ 9 local-scope 10 foo false/no-exception 11 foo true/raise-exception 12 ] 13 14 # example showing exception handling 15 def foo raise-exception?:bool [ 16 local-scope 17 load-inputs 18 # To run an instruction of the form: 19 # try f ... 20 # write this: 21 # call-with-continuation-mark 999/exception-tag, f, ... 22