On 12/05/2013 8:00 PM, Bill Myers wrote:
This is a suggestion for adding an exception system to Rust that
satisfies these requirements:
1. Unwinding does NOT pass through code that is not either in a function
that declares throwing exceptions or in a try block (instead, that
triggers task failure)
2. Callers can ignore the fact that a function throws an exception,
resulting in task failure
3. Callers can handle exceptions if desired, with the same syntax of
C++, Java and C#
(1) avoids the issue with C++ exception handling forcing to think about
exception safety everywhere
(2) avoids the issue with Java's checked exceptions forcing to
explicitly handle or redeclare them
(3) provides an easy-to-use exception mechanism
Hi, sorry, I did mean to get back to this.
I think this is ... unlikely to work out, or be something we incorporate
into our repo. For a few reasons:
- It's very late in the design cycle to be making changes of
this scope. We're trying to stabilize.
- It'll be a big performance hit on code paths that want to use
such exceptions. Things that look like "just function calls"
turn into quite extensive operations. We're already struggling
with the costs of a return-bool solution for unwinding on
platforms that have difficult "normal" EH (#4342).
- Most seriously: it doesn't actually resolve (1) or (2), imo.
(1) You'd still have to declare checked exceptions everywhere. But
worse than in java, if you failed to declare them _anywhere_
you wouldn't get a compilation error, but a runtime failure.
This is like making C++ default to 'throw ()', which tends
to surprise everyone.
(2) You still have to write in "worry about exceptions everywhere"
style inside a try-block or function-that-rethrows. Only
get to avoid it when you're insulating yourself by the implicit
"throw ()" declaration.
I'm sympathetic to the desire here, as with all attempts to "get
exceptions right". Sadly I've never really seen it; I don't think anyone
has really worked out the "right" way to work with catchable-exceptions
in a language.
-Graydon
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev