3 ms·
> If Rust decided to go all exception-happy, it could have an option to codegen all function calls as if they were wrapped in try! That's what I mean by overhe
by pcwalton 12y ago
> If Rust decided to go all exception-happy, it could have an option to codegen all function calls as if they were wrapped in try!
That's what I mean by overhead for even the non-throwing case.
> - or at least, all calls that can throw, a flag which can be either specified in declarations of stored in metadata, though not without some complexity in the latter case in order to handle separate compilation correctly.
That's checked exceptions, and I don't think they'd be a good fit for Rust for a few reasons that I've outlined in comments downthread, but briefly: (a) the annotation burden would be just as bad; (b) automatic unwrapping and wrapping of function result values could be surprising for systems programmers; (c) checked exceptions like Java don't allow for the nice .unwrap() syntax; (d) checked exceptions, as an out-of-band effect type, don't play as well with higher-order functions as just using the normal return value. But yes, it is possible.