Re:Golang implementation of Bentley/McIlroy compression
by pkulak on Thursday December 19, 2013 @01:31PM
(#6936626)
Named return parameters are unfortunate. Probably better to never use them unless you have to (like if you are "catching" a panic). Otherwise, I think you are nitpicking a bit.
[ Parent
| on HN ]
Re:Golang implementation of Bentley/McIlroy compression
by twotwotwo on Thursday December 19, 2013 @07:09PM
(#6938942)
I don't mind using named returns a lot--they can help to document, and sometimes they save you a declaration you were going to do in the method body anyway.
There are times they can be redundant (Sum(ints) does not need its return value named), or make the code less clear, or they indicate that you're trying to work around having overcomplicated methods by documenting them--I'm not saying always use them. But I don't try to avoid them.
Re:Golang implementation of Bentley/McIlroy compression
by frou_dh on Thursday December 19, 2013 @02:32PM
(#6937196)
That usage with recover would be to be able to set return parameters that might otherwise be returned as their zero values, correct?
Re:Golang implementation of Bentley/McIlroy compression
by pkulak on Tuesday December 24, 2013 @01:46AM
(#6958552)
Exactly. You can't return from the outer function in a defer, but you do have access to named return values. It's a bit of a kludge.
Re:Golang implementation of Bentley/McIlroy compression
by ihsw on Thursday December 19, 2013 @02:42PM
(#6937263)
What's wrong with named return parameters?
Re:Golang implementation of Bentley/McIlroy compression
by RamiK on Thursday December 19, 2013 @03:42PM
(#6937706)
http://golang.org/doc/effective_go.html#named-results
It's far more convenient looking at the function deceleration and knowing what comes and goes instead of hunting for return statements.