Laurel Language Designer Guide

10.4. Planned: Future channels for await🔗

A coroutine today can yield a value at each suspension but cannot return a final result: there is no channel for the completion value. The planned fix is to make a coroutine's channel carry a Future, the two-case status of a delayed computation:

datatype Future<A> { Pending(), Done(value: A) }

Every ordinary suspension yields Pending(); a return e desugars to yielding Done(e) once, at completion. A coroutine that returns an A is then exactly one whose channel is Future<A>. This one addition unifies three planned constructs: a coroutine return value (yield Done(e) and halt), a driver's read of the finished coroutine's result (the Done payload), and has_next (which becomes "is the status Pending?"). The async/await sugar then desugars to a loop that drives a delegate coroutine with resume until its status is Done, re-surfacing each Pending as the awaiter's own suspension.