On Tue, Jul 9, 2019 at 2:03 PM Henrik Johansson <dahankz...@gmail.com> wrote:
>
> Not sure if anyone has already mentioned the possibility that "try" could 
> actually improve error handling
> by simply removing much of the tediousness. Both reading and writing all the 
> error checks becomes a
> nail in my eyes even if realize that it is very important. What if "try" 
> could take some of that annoyance
> away and simply make me focus on handling the errors where appropriate and 
> pass on where convenient?

Consider a factorial function:

        func factorial(n int) int {
                if n < 2 {
                        return 1
                }

                return n*factorial(n-1)
        }

In the above function the check for n less than 2 is conceptually the
same as checking for an error/exceptional condition/value.

Seems that no one argues that the if statement in this function is
"verbose", "disrupting" or whatever.

I, for one, consider the if statement, regardless of it checking for
number or error value, always equally important. Trying to hide it
makes no sense to me.

But maybe the community really prefers the C version:

        int factorial(int n) { return n < 2 ? 1 : n * factorial(n-1) }

Me not.

-- 
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/CAA40n-UXNvR%2B8B%3DQPqgry%2BYcTAOLv4mm6otc7RyzR3Wrrihn0g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to