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

Dmitri Gribenko gribozavr at gmail.com
Tue Jan 26 01:24:42 CST 2016


On Mon, Jan 25, 2016 at 10:38 PM, Rob Mayoff via swift-evolution
<swift-evolution at swift.org> wrote:
> For example:
>
> return .Right(.Right(tree), sourcePos)
>
> The outer Right means Success; the inner Right means the right-hand branch
> of an alternation operator (I think).

Your example is a perfect illustration of the problem with Either --
it does not have domain-specific semantics attached, and thus
compromises readability.

You had to add an extra sentence to explain what a supposedly simple
line of code does, and even then you had to add "I think", which I
understood you used to express uncertainty about the explanation.  I
don't think promoting this kind of coding style is a goal for Swift.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/


More information about the swift-evolution mailing list