3 ms·
> The difference seems to be that Go has a preferred way to do it: explicit case analysis and early returns. There are other approaches but they're used much l
by pcwalton 12y ago
>
The difference seems to be that Go has a preferred way to do it: explicit case analysis and early returns. There are other approaches but they're used much less and rarely exposed in API's.
The API signature is always the same regardless of how the caller handles errors: a function returning Result. The differences are never exposed in APIs (arguably even less than in Go, since you can't recover from a panic in Rust except at thread boundaries).
> Meanwhile, apparently the Rust folks can't make up their minds, so they support lots of different functional styles of error handling.
They all boil down to the same thing. There's no inability to make up our minds with error handling any more than supporting both for-loops and map represents inability to make up our minds. Nobody dings Python for supporting list comprehensions in addition to for loops. Sometimes functional programming is short and sweet, and you should be able to use it; other times, for loops are better. and_then() is just the functional syntax to "try!"'s imperative syntax.
- skybrian 12y agoIt's good that the API signature is consistent. It seems like having lots of trivial error combinators is less like Python's list comprehensions and more like what came before it. I'll point out that Guido has had second thoughts about lambda, reduce(), filter() and map(), though in the end he only dropped reduce. [1]. [1] http://www.artima.com/weblogs/viewpost.jsp?thread=98196 http://www.artima.com/weblogs/viewpost.jsp?thread=98196