Overall -1.
No. I've worked probably over a dozen of Swift codebases in a variety of domains and on a variety of platforms. I'm also a big fan of adding nice things to make your project. Yet I've never had an instance where I needed or wanted Result
. I'm not exaggerating: zero times.
In day-to-day iOS programming, nearly all the errors that need to be handled are from asynchronous actions (naturally, it's the first example in the proposal) and all of those things are better handled with promises or futures. In that vein, I have written a Swift promise library and I use it in every iOS project I work on. Result
has frankly not been useful enough to me to justify its addition in any project, much less the standard library, and its value pales in comparison to something like Promise
.
I don't think so. The way this proposal is laid out, it adds a Result
type without any of the thoughtful interoperability that went into the way that, for example, Swift 2's throws
and defer
worked together. This proposal includes an initializer that takes a throwing block, but no compiler-level integration. i.e., you might expect to be able to:
let stringResult = String(contentsOfFile: configuration) // (stringResult is a Result, with no `try` or initializer required)
Instead, you have to use the Result
initializer. Using the Result { }
initializer is like living without optional promotion and having to explicitly wrap everything in .some
. Without Swifty stuff like that, this feature feels tacked on, mostly something to allow people to delete their own Result implementations from their projects.
I see the value in having incremental proposals, but I also think that Swift should be improved with granular changes that have merit on their own, rather than half-steps. If Swift's error system were originally designed with a nominal Result
type in mind, I would be less opposed.
As mentioned earlier, I've mostly worked with promise libraries, since I've never had a need for a Result type, but I've worked with Promises extensively and they have a very similar shape. That experience is part of what makes me think this doesn't hold its value.
Quick reading.