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

Separate exn types #27

Open
okeuday opened this issue Jun 12, 2022 · 2 comments
Open

Separate exn types #27

okeuday opened this issue Jun 12, 2022 · 2 comments

Comments

@okeuday
Copy link

okeuday commented Jun 12, 2022

It would be helpful to have two separate types for exceptions, with one type for recoverable exceptions and the other type for unrecoverable exceptions (i.e., fatal exceptions). The cleanest approach of this idea appears to be the Java class hierarchy with https://docs.oracle.com/javase/8/docs/api/java/lang/Exception.html for recoverable exceptions and https://docs.oracle.com/javase/8/docs/api/java/lang/Error.html for unrecoverable exceptions. Having that clear delineation helps to communicate the intent in the source code for potential failures.

My impression is that at least the ATS2 exceptions AssertExn and IllegalArgExn are unrecoverable because they represent a broken constraint in the source code.

If you didn't want to have exceptions in ATS3, that would be good too. That approach should be better for compiler optimizations like inlining.

@Necryotiks
Copy link

Recoverable exceptions are usually handled by Option or Result types.

@okeuday
Copy link
Author

okeuday commented Oct 15, 2022

@Necryotiks Yes, for referential transparency, that is preferred in any programming language. This issue was focused on "if exceptions exist, how should they be" because of experiences with ATS2 exceptions. The exit C function is seen as an exn side-effect and the atexit C function registers a function pointer that is similar to a catch of an unrecoverable exception (without exit existing as an exception), so the unrecoverable exceptions concept is common/old/useful even if it doesn't use exception types.

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