4 ms·
This is called the "result pattern". I would not call this a novel concept. In C# we use this: https://github.com/ardalis/Result https://github.com/ardalis/Resu
by Lord_Zero 1y ago
This is called the "result pattern". I would not call this a novel concept. In C# we use this: https://github.com/ardalis/Result https://github.com/ardalis/Result
- karmakaze 1y agoYes, I stopped reading at: > The most common approach is the traditional try/catch method.
- wavemode 1y agoWeird to stop reading at a statement that is factually true.
- hamstergene 1y agoReturning error codes was actually the first approach to error handling. Exceptions (try/catch) became widespread much later. The article got it backwards calling try/catch "traditional" and Go's approach "modern".
- bhawks 1y agoTyped try/catch was tried in Java. The typing was not well liked and people voted with their feet to untyped exceptions. Euphoria turned to misery and golang emerged with returning errors explicitly. Overall I would say that the return value and error value shouldn't be split as in Golang. A result type that forces the user to account for the error when accessing the return is a much better approach. The compiler should make it fast.
- kllrnohj 1y ago> Exceptions (try/catch) became widespread much later Exceptions, complete with try-catch-finally, were developed in the 60s & 70s, and languages such as Lisp and COBOL both adopted them. So I'm not sure what you're calling "much later" as they fully predate C89, which is about as far back as most people consider when talking about programming languages.
- karmakaze 1y agoNot in a codebase I develop or maintain. Nothing to see here, moving along.