I’ve been doing a bit of Io development in my spare time, and I wanted to bring forward a feature that really makes me happy.

The feature is called futures and here’s how it works:

val := futureSend(
# some longish operation
# some other things...
val println

When futureSend gets activated, it spins off a co-routine with the message passed to futureSend and starts working on it.

When the value returned from futureSend is actually used the operation blocks until the message has completed (if it hasn’t already), and then val becomes the return value of the message.

Its a very clean way to handle joining because they’re totally transparent, meaning that val may as well have been activated serially.

If you’re looking for a similar behavior other languages:

  • lazy.rb in Ruby
  • Future in Python
  • Google Javascript Futures as there's an entire discussion to be had about the best way to implement these.