The (Once and) Future Class

Please note that you can only access futures in the Racket-based interpreter.

The Future class gives you access to parallelism. An instance of the future class represents a delayed expression that the interpreter evaluates in parallel with other futures.

You can create a future by using the future funject:

my-future = future {[]: 'evaluate ' + 'me ' + 'in ' + 'parallel'}

The Future funject takes a funject and adds it to a metaphorical "pool" of other funjects to evaluate in parallel. When you want to evaluate a future, pass it to the touch funject:

touch my-future # returns 'evaluate me in parallel'

Between when you pass future an expression and when you touch the resulting future, the interpreter will evaluate the expression. By giving the interpreter the freedom to evaluate the expression any time during that period, you allow the interpreter to interleave it with the other futures and to evaluate it when it will consume the least resources. As a result, your program will probably run faster. It does take the interpreter thought to create a future, however, so use it only for significant computations.