3 ms·
> 4) Named return parameters are really stupid. This is another thing that doesn't fit the philosophy of what I understand Go to be. It forces a bunch of verbos
by camus2 9y ago
> 4) Named return parameters are really stupid. This is another thing that doesn't fit the philosophy of what I understand Go to be. It forces a bunch of verbose opinionated rules on us, but then allows named return parameters which causes confusion.
They exist because go really has exceptions. The only way to "catch" and modify variables in the "catch" before they are returned is to use named return values. You can't return anything from a panic/defer/recover directly. Error as value are just a convention.
https://play.golang.org/p/gRoUaVUs8M https://play.golang.org/p/gRoUaVUs8M
- barsonme 9y agoThey also help clarify what the return parameters are. It can be helpful if you have multiple if the same type (e.g., func Foo() (int, int))