2 ms·
> I have to rely on the doc comments to figure out whether a method can throw exceptions But you still have to rely on the docs to tell if a function can abort
by dataflow 3y ago
> I have to rely on the doc comments to figure out whether a method can throw exceptions
But you still have to rely on the docs to tell if a function can abort execution (say, by calling std::optional<T>::value() when there's no value). And an unhandled exception would abort just the same. Where do you see there being a difference?
> and which and when.
Maybe types don't tell you that either, you still need documentation for that.
Even worse, Maybe types cannot tell you that unless they're leaf-ish functions. Because they may call opaque functions (such as your own callbacks) for which they have no such knowledge to begin with. Thus they have to support propagating some type-erased error type... which is exactly what exceptions do.
So, again: how is the situation different?