Skip to content

Instantly share code, notes, and snippets.

View wudijimao's full-sized avatar
🎯
Focusing

wudijimao wudijimao

🎯
Focusing
View GitHub Profile
@wudijimao
wudijimao / async_swift_proposal.md
Created July 25, 2018 05:34 — forked from oleganza/async_swift_proposal.md
Concrete proposal for async semantics in Swift

Async semantics proposal for Swift

Modern Cocoa development involves a lot of asynchronous programming using blocks and NSOperations. A lot of APIs are exposing blocks and they are more natural to write a lot of logic, so we'll only focus on block-based APIs.

Block-based APIs are hard to use when number of operations grows and dependencies between them become more complicated. In this paper I introduce asynchronous semantics and Promise type to Swift language (borrowing ideas from design of throw-try-catch and optionals). Functions can opt-in to become async, programmer can compose complex logic involving asynchronous operations while compiler produces necessary closures to implement that logic. This proposal does not propose new runtime model, nor "actors" or "coroutines".

Table of contents