Re:Why Go Is Not Good (2014)
by acjohnson55 on Wednesday December 09, 2015 @03:11PM
(#10706365)
As a Scala coder, I'd say you can have it both ways by encoding the result as type that can have success or failure cases. No fancy control flow needed, just pattern matching.
[ Parent
| on HN ]
Yeah, and you can implement that in C++ very easily, too. Googlers might recognize StatusOrReturn, and similar macros.
You don't get pattern-matching though, and I expect the implementation would be somewhat gnarly without native tagged unions. At least now that C++ has lambda expressions you can get all the nice HoF so the usage side of the equation has become less troublesome.
Still, a far cry from
data Result a b = Err a | Ok b