3 ms·
> Given that this is a feature that should be used very sparingly, and also one that is very apt to be misused While it should be used carefully, perhaps it ne
by vacuity 2y ago
> Given that this is a feature that should be used very sparingly, and also one that is very apt to be misused
While it should be used carefully, perhaps it need not be used sparingly. My main concern is that unwinding panic occupies a weird role of being both a way to crash and a catchable exception, and I think the former should be distinct and the latter should be integrated more nicely with normal Result bubbling, essentially doing the same thing but focusing on performance and readability on the happy path.
> As far as cost, it depends on the arch and its ABI
In Rust, panic branches are ubiquitous and the compiler's optimizations are hindered by the fact that mostly anything might panic. If there was an easy way to indicate that in this specific instantiation, integer overflow definitely won't happen, a panic could be avoided. In order to avoid unsafe, I imagine it would be something like contracts or mini theorem provers, though, which is only helpful if they're already being used.