C++ Logo


Advanced search

Re: Middle ground between "return" and exceptions?

From: Dusan Jovanovic (DBJ) <"Dusan>
Date: Mon, 21 Sep 2020 12:38:00 +0200

Simon Brand has written an optional with functional programming methods
<https://github.com/TartanLlama/optional> added .. *and_then *and the rest.
That does seem like a ready-made solution for you?

On Wed, 16 Sep 2020 at 09:24, Dmitry Dmitry via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> So it it's actually a nasty hack, which both looks like it was using
>> coroutines, and simultaneously prevents you from actually using them as
>> intended moving forward.
>> > either false (in which case we effectively return from FindUsersCity
>> and it corresponds to some error),
>> And that's where you already fell for that misconception. It does not
>> return from FindUsersCity, but it aborts execution of the whole coroutine
>> context. Like an uncaught exception, unrolling the whole stack with it.
> I might be wrong, but what do you think about this?
> What if, instead of std::optional<> we have our own custom type (say,
> Result<Ok, Err>) that will be aware of such a hackish usage of coroutines?
> Resumable can be implicitly converted to Result<>. And when the return
> value (Result<>) is initialised from Resumable it can destroy coroutine...
> In this way we will not need a wrapper. Will it work? Am I right? :)
> --
> Dmitry
> *Sent from gmail*
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2020-09-21 05:38:19