-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Awaitable operations inside try block #89
Comments
Probably because this is incompatible with the machine state. I did a await/async for jvm some time ago: But at bytecode level. Manipulating the AST is a different story. But that doesn't mean that supporting try...catch blocks, is impossible. I have another proposal implementing this: try {
stm1
val result = await(future1)
stm2
} catch (e) {
case e:Exception =>
} -> class MachineState(var local1, var local2, var state, var error)
while (state.state != 5) {
state.state match {
case 0 => try { stm1; state.state = 1 } catch (e) { state.state = 4 }
case 1 => try {
future1.then(v => resume(2, v, null))).otherwise(e => resume(4, null, e))
return
}
case 2 => try { stm1; state.state = 3 } catch (e) { state.state = 4 }
case 3 => done()
case 4 => {
// Transform the match from the catch statement, with a normal match
e match {
case e:Exception => state.state = ...
}
}
}
} |
I implemented support for Contributions for porting this to the current |
The rebase is just merge manually all the commits related to try-catch-finally? Or the api has changed since then? |
A few things internal to the Following a PR, there might be a few more issues to address, of course. Just to be clear that the implementation is probably not 100% done. :-) |
I believe we can and should do better than generating a |
Why not support awaitable operations inside try block, by translating
try{
F
} catch {
G
} finally {
H
}
to something like: async(F).recoverWith(G).onComplete(H) ?
The text was updated successfully, but these errors were encountered: