▲ | OtomotO a day ago | |||||||
But with Exceptions you can easily implement multiple return types in e.g. Java ;) I shocked my Professor at university with that statement. After I started laughing, he asked me more questions... still went away with a straight A ;D | ||||||||
▲ | Cthulhu_ a day ago | parent | next [-] | |||||||
As you should, it shows a deeper insight in the language beyond the base course material and out of the box (and cursed) thinking. | ||||||||
▲ | Yoric a day ago | parent | prev | next [-] | |||||||
In OCaml, that's actually a common use for exceptions, as they let you unwind extremely quickly and carry a result (helped by the fact that OCaml doesn't have finally or destructors). | ||||||||
▲ | sshine a day ago | parent | prev [-] | |||||||
When I took the compiler course at university, the professor would have a new coursework theme every year, and the year I took the course, the coursework compiler was exception-oriented. So exceptions were the only control flow mechanism besides function calls. If/else, while, return were all variations of throw. To me this proved that there's nothing inherently wrong about exceptions. It's how you structure your code and the implied assumptions you share with your colleagues. Some people are way too optimistic about their program will actually do. Happy path programming. | ||||||||
|