On Tue, Dec 20, 2016 at 10:31 AM, Ehsan Akhgari <ehsan.akhg...@gmail.com>
wrote:

> >   Result<V, E> Baz() { MOZ_TRY(Bar()); ... }
>
> I have one question: what is Bar() expected to return here?


Result<T, F> where F is implicitly convertible to E.

  An E type,
> or a type that's implicitly convertible to E
> (<https://searchfox.org/mozilla-central/rev/cc2a84852bd4e6f6d8d4d5b17b8382
> bb5d005749/mfbt/Result.h#198>
> suggests that this is the case), or something else?


The implicit conversion solves a real problem. Imagine these two operations
have two different error types:

        MOZ_TRY(JS_DoFirstThing()); // JS::Error&
        MOZ_TRY(mozilla::pkix::DoSecondThing()); // pkix::Error

We don't want our error-handling scheme getting in the way of using them
together. So we need a way of unifying the two error types: a shared base
class, perhaps, or a variant.

Experience with Rust says that MOZ_TRY definitely needs to address this
problem somehow. C++ implicit conversion is just one way to go; we can
discuss alternatives in the bug.

-j
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to