What are futures?

后端 未结 7 1204
长发绾君心
长发绾君心 2021-02-13 09:37

What are futures? It\'s something to do with lazy evaluation.

7条回答
  •  囚心锁ツ
    2021-02-13 10:27

    A Future encapsulates a deferred calculation, and is commonly used to shoehorn lazy evaluation into a non-lazy language. The first time a future is evaluated, the code required to evaluate it is run, and the future is replaced with the result.

    Since the future is replaced, subsequent evaluations do not execute the code again, and simply yield the result.

提交回复
热议问题