Difference between next() and then()? (package `future`)

Timon Gehr timon.gehr at gmx.ch
Mon Aug 17 13:04:51 UTC 2020


On 17.08.20 04:57, Victor Porton wrote:
> https://code.dlang.org/packages/future
> 
> What is the difference between next() and then()

Consider using the d.D.learn forum.

`then` is map and `next` is bind. I.e.,

Given a function from S to T, `then` maps a Future!S to a Future!T.

Given a function from S to Future!T, `next` maps a Future!S to a Future!T.

The implementation of next!f is then!f.sync:
https://github.com/evenex/future/blob/master/source/future.d#L272

Where `sync` maps a Future!(Future!T) to a Future!T, by waiting for the 
outer and inner futures in turn:
https://github.com/evenex/future/blob/master/source/future.d#L281


More information about the Digitalmars-d mailing list