[swift-evolution] [proposal] Either in the Swift Standard Library

Dave Abrahams dabrahams at apple.com
Wed Jan 27 00:48:37 CST 2016


on Mon Jan 25 2016, Kevin Ballard <swift-evolution at swift.org> wrote:

> Then we are fundamentally at odds, because I am categorically opposed
> to any solution that does not have specific meaning attached to the
> two variants. Either is an awful type that only serves to make APIs
> harder to understand, and literally every non-trivial usage of Either
> I’ve actually seen in practice, it has been used exactly the way
> Result<T> would naturally be defined (where “trivial” means usage in
> any kind of actual API, as opposed to sample code or scratch functions
> using Either to prototype something that, if turned into actual API,
> would replace the usage of Either with a more well-defined enum). And
> the existence of Either only serves to encourage people to use it,
> which produces an overall negative effect on the quality of APIs.
>
> -Kevin Ballard

I think I agree with Kevin.  Unlike Kevin, I don't have much real
experience with code using an Either type to draw on, so I can't say
this with quite as much conviction, but I've always felt that, if there
is a use-case for Either, it's certainly *not* "return-value-or-error,"
which ought to have a more descriptive name and implication of
semantics.


-- 
-Dave



More information about the swift-evolution mailing list