3 ms·
Exceptions are a return type of functions. They return via a different path but there is no possible way you could disagree that they are a form of return.
by zaphar 4y ago
Exceptions are a return type of functions. They return via a different path but there is no possible way you could disagree that they are a form of return.
- layer8 4y agoExactly my point?
- dllthomas 4y agoI understood it to be intended as agreement with emphasis.
- dllthomas 4y agoAs they don't return to the same place, don't return to a single place, and may (if not caught) not actually return but instead take down the entire thread, I think it's reasonable that for some purposes it might well make sense to treat exceptions as something other than "a form of return." ¯\_(ツ)_/¯ However we're treating them, however, I agree that they are a part of the interface and should be documented (and, where relevant, checked) as such.
- int_19h 4y agoThe point is that the type system doesn't properly reflect that. You should be able to declare a generic method that takes some T, and throws everything that T.foo() throws, for example.