Of course, you can write code that does not use exceptions. However, if you do, you would make sure that any function that might throw an error is handled properly.
For me, the biggest advantage of having exceptions is that I can write direct code that simply assumes that all functions succeed, knowing that the upper levels will take care of error messages.
Specifically, take the following dummy function for working with text in the editor:
do-stuff: backward-line 10 x = point search-for "FOO" return buffer-substring x point
Both the return line and the search can fail. If I had to handle the errors myself, I would check them. In addition, I would have to invent a side channel to inform my subscriber that an error has occurred. As I said, this can be done, but it would be much dirtier.
Lindydancer
source share