Re:Reasons for using Golang
by sid0 on Sunday June 12, 2011 @11:31PM
(#2648018)
Tons of functions in most imperative languages are structured in an early-return-on-error style, with exceptions simply being a special case of that. That is neither novel nor uncommon.
[ Parent
| on HN ]
Re:Reasons for using Golang
by JulianMorrison on Monday June 13, 2011 @07:15AM
(#2648679)
But not with multiple return where (as an idiomatic design pattern) the same error object is passed up through the call stack until something decides to handle it, which is what the Either monad does. (And unlike exceptions, the Go way and the Either monad are both explicit, there are no unmarked returns.)
The C way with single return means that it's generally impossible to just forward the same error object - the caller has a different type from the callee, so where one returns null another has to return -1, and so forth.