dart-lang/async_await — pull request #52 by kmillikin (2014-09-19 11:54:26+00:00)
Title: Break chains of futures arising from await in a loop.

Await inside a loop can create arbitrarily long chains of futures.
Break these at the point of the loop's continue function, but ignoring
the return value from continue and instead communicating completion
values or errors via a Completer per loop.

This is awkward because calls to .then() from await inside a loop need
to install an error handler to propagate errors to the completer.

Two important things change about the implementation:

* Return continuations previously had type `unit -> unit`, now they
have type `expr -> expr`. Before they had the side effect of
emitting a sequence of statements that always ended with a
`return`. Now we need to be able to wrap the subexpression of the
`return`, so they have the side effect of emitting a sequence of
statements (the same as before) and returning the subexpression of
the `return`.

* Break and continue labels previously were strings, because they
were always named functions. Now we need to ability to wrap them
so that they generate code, so they have type `unit -> unit`.