SE-0317: Async Let

Yeah, this is going to be one of the most fraught parts of the new model. We’ll all have to get used to the fact that every time there’s an await, visible mutable state may change without notice. The sequential appearance of async/await code makes concurrency look dangerously easy! That is one of its downsides.

Thinking aloud here, we need to make sure (in most cases) that an object/actor’s invariants hold before every single await, not just at the end of every public function. I imagine we’ll develop a toolbox of common practices to help with this, e.g.:

  • Isolating complex state manipulations that temporarily clobber invariants to non-async functions.
  • Holding more intermediate state in local variables, then writing it all back to ivars in one non-awaiting swoop at the end.

Whatever the ultimate terminology and syntax, I see the async let proposal as being helpful on this front, e.g. with implementing that second pattern.