On 1/12/2015 6:57 AM, Martin Nowak wrote:
The general solution in functional programming is error chaining.
An example, C is a function that reads in lines of a program and B is a function
that takes all those lines and counts words.
C will either return an error or lines and B will either immediately return that
error to A or convert the lines to word counts.
This works especially well with function chaining, because you can hide the
error propagation in a generic chaining method (called map).

http://danielwestheide.com/blog/2012/12/26/the-neophytes-guide-to-scala-part-6-error-handling-with-try.html


Yes, it still appears to be just a wrapper around returning two values, and that has to be done for everything.

There's another downside to returning two values - extra code is generated, and it consumes another register. It allocates very scarce resources to rare cases - not a recipe for high performance.

Reply via email to