On Tue, Jul 9, 2019 at 1:57 PM Jan Mercl <0xj...@gmail.com> wrote:

> It's not verbosity. It's error handling. And because error handling is
> usually not the happy path, it's good when it stands out clearly. That
> improves readability as the important part catches attention easier.
>

I agree that the "sad" path is as important as the "happy" path, but I
wouldn't say it's more important to the point of dominating the number of
lines in a function. In some functions, 2/3 or 3/4 of the lines are
dedicated to error handling.


> Hiding important code in one line instead, or with even using nested
> try constructs, makes the important path easier to overlook or to not
> be aware of it at all.
>

try "hides" nothing. try is only useful for returning the error. If there
is some important error handling code in the if statement block, then try
cannot be used and the code stays the same.

Don't you think we could get used to try after using it a bit? This is what
happens to Steve Klabnik when the ? operator was added to Rust. He was
against it, and changed his mind after writing code using it.

-- 
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/CAG3yVS6W2SXaeHQYia%2BtynPk5vC1gMkBz6%3DgXjacCe1OQSD3CA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to