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

Use closure instead of macro #1

Open
rmccrystal opened this issue Nov 3, 2021 · 2 comments
Open

Use closure instead of macro #1

rmccrystal opened this issue Nov 3, 2021 · 2 comments

Comments

@rmccrystal
Copy link

Would it be possible to introduce a function similar to std::panic::catch_unwind that runs the closure under the exception handler and returns a Result<T, *const Context> indicating the status of the execution? Macros are generally harder to use than functions if the option is available because the syntax isn't always intuitive.

@CasualX
Copy link
Owner

CasualX commented Nov 8, 2021

Hi, sorry for the late reply.

I think I explored this but it's complicated because of closure capturing.

If it was a single callback then yes it would be simple. But it's 3 callbacks. If there's no state overlap then it's again simple. These callbacks 'overlap' causing borrow errors if you want to be able to mutate shared data in the closures.

This can be fixed with an explicit trait with 3 methods on it but marshalling this trait object over C++ isn't simple. Maybe I can give it another try but this code was just a simple hack job to see if it was possible at all.

@CasualX
Copy link
Owner

CasualX commented Nov 8, 2021

I'm also not sure what you mean by similar to std::panic::catch_unwind: I'm not sure it can express the actual idea of __try __except (and I don't even handle __try __finally which I remember does not compose with __except).

Finally I don't even know or understand the full idea of SEH (only that you can use it to catch access violations) so I'm not even sure how to implement all of this.

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

No branches or pull requests

2 participants