On Sun, Jun 30, 2019 at 4:16 AM robert engels <reng...@ix.netcom.com> wrote:
>
> I am not sure the ‘unexpected flow control’ concern is of the same importance 
> as when this statement was first written, given paradigms like ‘reactive 
> programming’ (I don’t like it, but it seems most others are not bothered by 
> it).
>
> I am curious more though in the belief that exceptions are unexpected flow 
> control. At least with caught exceptions, this is not the case IMO. You know 
> the exact point at which the exceptions can occur - this is part of the 
> beauty of exceptions in that the code is self documenting to a higher degree 
> and can be subject to automated analysis far more easily 
> (https://arxiv.org/pdf/1708.00817.pdf) In principle, every error in Go should 
> be handled, but the compiler does not enforce this. I also think that 
> try-with-resource solves many of the life-cycle concerns very elegantly 
> (whether you like Java or not, a lot can be learned from the evolution the 
> language). Still caught exceptions cause problems with functional methods 
> (and so does error return), although I’m not a big fan of functional either 
> (for lack of readability).

The unexpected flow of control when using exceptions is not at the
point where the exception is thrown, nor at the point where the
exception is caught.  It is the functions in between that point.  When
exceptions are used routinely, every single function call is a
possible change in flow of control.

That is of course true in Go today because any function may call
panic, but we we can cope with that in practice because calling is
panic is discouraged and rare, especially if an unrecovered panic
crosses a package boundary.  But errors must be routinely returned
across package boundaries, so if we use exceptions to handle errors
then we inevitably have unexpected flow of control.

This is hardly a novel view, of course.  E.g.,
https://www.joelonsoftware.com/2003/10/13/13/ .

And since Go programs routinely require transferring an error between
one goroutine and another, in Go we would have to have to some clean
and simple way to transfer an exception between goroutines.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcVJiXjVbxRCidDrN7hfwiftqs280on2fuwypPphJqpC1g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to