Implementing Futures
This lesson describes Go’s “futures”, which allow the calculation of values beforehand using lazy evaluation and channels.
We'll cover the following...
Introduction
A related idea to lazy evaluation is that of futures. Sometimes, you know you need to compute a value before you actually need to use the value. In this case, you can potentially start computing the value on another processor and have it ready when you need it. Futures are easy to implement via closures and goroutines, and the idea is similar to generators, except a future needs only to return one value.
Explanation
Suppose we have a type Matrix
, and we ...