Handling asynchronous exceptions ================================ Limitations: * Async exception handlers must NOT see program state (it may have been destroyed or in an inconsistent or "impossible" state). * Exception handlers could be an additional `entry` in the service implementation. The exact behavior could vary between different service types. * State that needs to be preserved could be stored in a `giveme`. It would either have to be "taken" (as a linear type) or it would have to be serialized. (Maybe that could be an implementation detail? Serialization could be the default, and pass-as-linear-type could be an optional optimization). - A linear/affine type would avoid bugs, where the programmer keeps the reference and thinks that updates to it would update the copied/ serialized object. Example code: giveme int param = param "-n" ErrorState! int current_step = defval 0 MessageReporter! mr end entry main code current_step.set 1 # could trigger a division by zero exception int i = 10 / param current_step.set 2 int i = 10 / (param-1) end entry exception code # It should only be possible to access `giveme`s that have been # marked as exception safe. How to implement that in the language? # OR maybe require all non-constant `giveme`s to be exception-safe, # and NOT be able to generate exceptions themselves? mr.error "Failed at step {}" current_step.get end