Skip to content
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

Experiment with a Catch node to help with flow control around tri-state subtrees #112

Open
jbcpollak opened this issue Feb 5, 2020 · 1 comment

Comments

@jbcpollak
Copy link
Contributor

this might end up getting too verbose, but something like the following might help manage exception cases:

const catchTree = new Catch(EXCEPTION_CODE, tryTree, successTree, exceptionTree, finallyTree);

I'm not really sure what form the EXCEPTION_CODE would look like or how tryTree would know how to throw it - perhaps a specially monitored ResultCode?

@jbcpollak
Copy link
Contributor Author

@mgabeler-lee-6rs:

I think the "safety" I was envisioning would involve not specifying the exception code in the ctor ... which would then imply that at least the tryTree would have to be a factory, not a pre-built tree, so the Catch ctor could pass the created code into that factory

fair point, also its almost like the tryTree should declare its possible ResultCodes and the overall tree should make sure all possible ResultCodes are handled. Like how Java handles exceptions

@mgabeler-lee-6rs

you could have some typescript voodoo for that...
though I think the number of generic type args you'd need in some places would get very hairy very fast
but I also figured that, in the context of a BT, it seems like you really have no business pretending you can catch things you don't know what are, and conversely you shouldn't be throwing things if you don't know what's going to happen with them

that to me seems like an argument to use TS voodoo, crazy typing be damned. I agree it could get out of hand though. I'd love to find the time to experiment with an implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant