6 ms·
I agree that functions should specify in their signature wether and how they fail, but checked exceptions can do that. Additional call site syntax is indeed jus
by gpderetta 5y ago
I agree that functions should specify in their signature wether and how they fail, but checked exceptions can do that. Additional call site syntax is indeed just noise. I strongly agree with David Abrahams[1] on this. A better solution would be noexcept regions were the compiler would statically guarantee that they can't be left via exceptional control flow.
[1] https://forums.swift.org/t/on-the-proliferation-of-try-and-soon-await/42621 https://forums.swift.org/t/on-the-proliferation-of-try-and-s...
- zozbot234 5y ago"noexcept" regions would be even noisier than the established pattern of non-fallible calls as the default and some lightweight syntax (such as '?' in Rust) to indicate fallibility. Sure, if literally all calls were fallible the '?' or equivalent would be redundant to call syntax, but everyone knows that this is not the case. And it's important that the failure-prone case be acknowledged as such.
- gpderetta 5y agoYou would use noexcept only around any code modifying an invariant you need to protect.