3 ms·
> > Exceptions don't exist > > They're called panics. Nope. https://doc.rust-lang.org/std/panic/fn.catch_unwind.html https://doc.rust-lang.org/std/panic/fn.c
by inferiorhuman 9y ago
> > Exceptions don't exist
>
> They're called panics.
Nope.
https://doc.rust-lang.org/std/panic/fn.catch_unwind.html https://doc.rust-lang.org/std/panic/fn.catch_unwind.html
- quotemstr 9y agoIt's non-local control flow with deterministic unwinding and defined stop points. It's an exception system. Sure, it's not "recommended", but recommendations don't define semantics.
- geofft 9y agoI'd say they do—a Rust user will never encounter a panic from a reasonable library that they're expected to catch. If hypothetical unreasonable libraries are in scope, they can just open /proc/self/mem for writing (in safe Rust!) and violate memory safety, and that's not an argument that Rust isn't memory safe. So why should hypothetical unreasonable libraries be an argument that Rust has exceptions?
- quotemstr 9y agoBecause the language doesn't define what happens if you write to memory behind the runtime's back. It _does_ define, in detail, what occurs on panic. It's a legal thing to do. That some consider panicing in bad taste or whatever does not change the fact that panic is a supported feature of the language.
- steveklabnik 9y agoIt also defines that it may abort, and so culturally, people use them for only what’s intended, as otherwise, it limits your audience.