Benjamin Mahler created MESOS-3226:
--------------------------------------

             Summary: Introduce an Either type.
                 Key: MESOS-3226
                 URL: https://issues.apache.org/jira/browse/MESOS-3226
             Project: Mesos
          Issue Type: Improvement
          Components: stout
            Reporter: Benjamin Mahler


We currently don't have an abstraction in stout to capture the notion of having 
a container with many types and a single value. For example, in our 
abstractions like Try, rather than being able to say {{Either<Error, Value> t}} 
we must encode two Options ({{Option<Error>}}, {{Option<T>}}) with the implicit 
invariant that exactly one will be set.

This also comes in handy in many other places in the code. Note that we have 
the ability to (1) use C++11 unions now, as well as (2) use boost's variant 
directly instead of introducing Either. However, creating a named union every 
time this is needed is verbose, and unions require that we externally track 
which member is set. For variant, we already use this (e.g. json.hpp), but we 
can benefit from the better naming as Either.

Many languages expose Either as having only two values, left and right. I'd 
propose making this two or more, as is the case with variant.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to