The difference between lazy pricing and promises / futures

What is the difference between promise or future and a lazily evaluated function/object ?

Both of them act as a placeholder for deferred calculations, and I understand that the principles they act on are different, but what is the actual difference?

+6
source share
1 answer

Both promises and "lazily evaluated objects" are proxy forms. Proxy is the key word here. Proxy means "placeholder for the actual value of the object"

  • A promise is a temporary (temporary) proxy for a value. Some libraries, such as Kris Kowal Q-Connection, even allow proxies to remote objects using promises, and there are many fascinating studies (really!) About this use case in hostile conditions made by Mark Miller. In fact, it was the original motivation for promises (to solve the problem with network latency).

  • The lazy evaluated object is a proxy for the value, to defer the evaluation to the point where you should do it.

+3
source

Source: https://habr.com/ru/post/969587/


All Articles