www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Difference between next() and then()? (package `future`)

reply Victor Porton <porton narod.ru> writes:
https://code.dlang.org/packages/future

What is the difference between next() and then()
Aug 16 2020
parent Timon Gehr <timon.gehr gmx.ch> writes:
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
Aug 17 2020