Re:Functional exceptionless error-handling with optional and...
by kindfellow92 on Sunday December 03, 2017 @05:22PM
(#15839992)
> They only execute instructions when they happen... but they still inhibit the optimizer when they don't. Calls that may throw act like branches in the control flow graph.
This is a fair point and elucidates the trade off being made. Perhaps this is the reason C++11 has the “nothrow” attribute.
Re:Functional exceptionless error-handling with optional and...
by kindfellow92 on Sunday December 03, 2017 @05:18PM
(#15839967)
It’s not exactly tied to that implementation but because error sum types are runtime values, it’s not clear whether a statement like “return foo” should return a normal value or do stack unwinding.
They only execute instructions when they happen... but they still inhibit the optimizer when they don't. Calls that may throw act like branches in the control flow graph. They also introduce more code bloat for their landing pads.
> Rust’s model for errors is tied to a specific implementation.
The Rust ABI is unspecified for a reason. We're currently seeing a lot of optimization around struct and enum layout; I'm not sure why this couldn't be applied to the calling convention without any extra syntax for "throw."