Re:Removing Garbage Collection from the Rust Language (2013)
by fweimer on Monday September 11, 2023 @08:33AM
(#37466272)
Rust has exceptions. They are used throughout the standard libraries to report some errors, and as far as I can tell, they are deeply ingrained into the default testing framework.
As a rule of thumb, languages that loudly claim not to have exceptions actually use them in some way (see POSIX C, Perl, Go).
Re:Removing Garbage Collection from the Rust Language (2013)
by TwentyPosts on Monday September 11, 2023 @09:04AM
(#37466645)
Saying that Rust "has exceptions" is dishonest. What matters isn't whether they technically exist, but if and how they're used.
In idiomatically written Rust you will never obtain an exception/panic (unless there is a bug), and exceptions are not used for control flow. This is not the case in Java or C++ or many other languages.
Re:Removing Garbage Collection from the Rust Language (2013)
by fweimer on Monday September 18, 2023 @01:32PM
(#37559230)
I don't know. It seems fairly common to use std::panic::catch_unwind as a top-level error handler. compiler/rustc_driver_impl/src/lib.rs has this:
/// The compiler currently unwinds with a special sentinel value to abort
/// compilation on fatal errors. This function catches that sentinel and turns
/// the panic into a `Result` instead.
That's clearly using unwinding as a control flow primitive.There's another example in src/tools/rustfmt/src/lib.rs, in format_snippet, where panics apparently are just suppressed.
I expect application servers for Rust to handle panics in a similar way: abort a specific request, but not terminate the whole process.
1. ADTs with exhaustive pattern matching
2. No exceptions
3. Zero cost generics
4. Traits
5. No nulls
6. No inheritance