To make exceptional handling robust, I think every exception needs to be explicitly handled somewhere. If an exception not handled by a function, that fact must be specified in the function declaration. In effect the compiler can check that every exception has a handler somewhere. I think you can implement it using different syntactic sugar than Go’s obnoxious error handling but basically the same (though you may be tempted to make more efficient).

 On Mar 10, 2023, at 6:21 AM, Larry Stewart <stewart@serissa.com> wrote:

TLDR exceptions don't make it better, they make it different.

The Mesa and Cedar languages at PARC CSL were intended to be "Systems Languages" and fully embraced exceptions.

The problem is that it is extremely tempting for the author of a library to use them, and equally tempting for the authors of library calls used by the first library, and so on.
At the application level, literally anything can happen on any call.

The Cedar OS was a library OS, where applications ran in the same address space, since there was no VM.  In 1982 or so I set out to write a shell for it, and was determined that regardless of what happened, the shell should not crash, so I set out to guard every single call with handlers for every exception they could raise.

This was an immensely frustrating process because while the language suggested that the author of a library capture exceptions on the way by and translate them to one at the package level, this is a terrible idea in its own way, because you can't debug - the state of the ultimate problem was lost.  So no one did this, and at the top level, literally any exception could occur.

Another thing that happens with exceptions is that programmers get the bright idea to use them for conditions which are uncommon, but expected, so any user of the function has to write complicated code to deal with these cases.

On the whole, I came away with a great deal of grudging respect for ERRNO as striking a great balance between ease of use and specificity.

I also evolved Larry's Theory of Exceptions, which is that it is the programmer's job to sort exceptional conditions into actionable categories: (1) resolvable by the user (bad arguments) (2) Temporary (out of network sockets or whatever) (3) resolvable by the sysadmin (config) (4) real bug, resolvable by the author.

The usual practice of course is the popup "Received unknown error, OK?"

-Larry

On Mar 10, 2023, at 8:15 AM, Ralph Corderoy <ralph@inputplus.co.uk> wrote:

Hi Noel,

if you say above that most people are unfamiliar with them due to
their use of goto then that's probably wrong

I didn't say that.

Thanks for clarifying; I did know it was a possibility.

I was just astonished that in a long thread about handling exceptional
conditions, nobody had mentioned . . . exceptions.  Clearly, either
unfamiliarity (perhaps because not many laguages provide them - as you
point out, Go does not), or not top of mind.

Or perhaps those happy to use gotos also tend to be those who dislike
exceptions.  :-)

Anyway, I'm off-TUHS-pic so follow-ups set to goto COFF.

--
Cheers, Ralph.