|
|
|
|
|
by curun1r
3224 days ago
|
|
False. That feature allows a more efficient implementation, but (T, error) (or an equivalent struct) can be reasoned about in much the same way as Result<T>. You don't need a tagged union when you can use the nil-ness of one of the two values in the tuple as the tag. Similarly, Option<T> is just a wrapper around a nullable T. |
|
Golang has all these weird performance pitfalls that you only hit if you contort the language too hard. Naming combinatior functions sometimes trips those conditions.
I'm of the opinion that even just pattern matching and the kind of nil type propagation checking that TypeScript does could help enourmously.
Generics won't fix error handling without compiler help, and the best way to get that help is to introduce pattern matching as a forcing function.