3 ms·
In Rust (I don't know about Go), there's a sharp line between "panic" and other error handling: the unwinding on a "panic" is optional. A program or library mig
by cesarb 8y ago
In Rust (I don't know about Go), there's a sharp line between "panic" and other error handling: the unwinding on a "panic" is optional. A program or library might be compiled with "panic=unwind", or it might be compiled with "panic=abort" where a panic kills the whole process instead of trying to unwind. This means "panic" can't be used for normal error handling, only for "can't happen" errors like an out-of-bounds index into a slice.
In your categorization, Rust with "panic=abort" would be at step 2, not 5 (and it's used in production that way, for instance AFAIK Firefox uses "panic=abort"). And interestingly, not unwinding on panic in Rust is newer than unwinding on panic: it was added only on Rust 1.10 (https://blog.rust-lang.org/2016/07/07/Rust-1.10.html https://blog.rust-lang.org/2016/07/07/Rust-1.10.html). So Rust seems to be following your list of steps somewhat backwards.