Boost logo

Boost :

Subject: Re: [boost] [next gen future-promise] What to call the monadicreturn type?
From: Peter Dimov (lists_at_[hidden])
Date: 2015-05-28 14:34:47

Niall Douglas wrote:

> On 28 May 2015 at 21:14, Peter Dimov wrote:
> > I wasn't suggesting removing .then, just adding .next. It's useful when
> > I need to perform the same action regardless of whether I got a value or
> > an exception.
> I'm a bit confused. If you want some action to occur regardless, you
> surely ignore the future you are passed in your continuation?
> Or by next(), do you mean that the continuation must fire even if no value
> nor exception is ever set, and is therefore fired on future destruction?

What I mean is:

    .then( []( future<T> ft ) { /*...*/ } )

    Used when I want to, for instance, send ft to someone via message

    .next( []( T t ) { /* ... */ } )

    Fires when ready() && has_value(). Used when I only care about results.

So, for example, when I do

    auto r = async(f1).next(f2).next(f3).next(f4).get();

I don't care which of the four steps has failed with an exception.

That's as if I write

    auto r = f4(f3(f2(f1())));

If one of these functions throws, I just get an exception, I don't care from
where. It's the same with .next.

Boost list run by bdawes at, gregod at, cpdaniel at, john at