Skip to content

Instantly share code, notes, and snippets.

View nsoojin's full-sized avatar
:octocat:
making stuff

Soojin Ro nsoojin

:octocat:
making stuff
View GitHub Profile
@godrm
godrm / swift_api_guideline.md
Last active March 27, 2024 05:15
스위프트 API 가이드라인

1. 스타일/문법 리뷰

1-1 스위프트 API 디자인 가이드라인

https://swift.org/documentation/api-design-guidelines/

  • 사용할 때 기준으로 명확하게 작성하는 게 가장 중요한 지향점이다. 메소드나 프로퍼티 같은 개발 요소는 한 번만 선언하고 반복적으로 사용한다. API를 만들 때는 사용하기 명확하고 편하게 만들어야 한다. 설계를 검증할 때 선언 부분을 읽는 것만으로는 부족하다. 그 대신 사용하는 상황에서 맥락에 맞고 명확한 지 늘 고려해야 한다.

  • 명확한 표현이 압축한 간결성보다 더 중요하다. 스위프트 코드는 압축해서 간결하게 작성할 수 있지만, 단지 글자수를 줄여서 가장 짧은 코드를 만드는 게 목표는 아니다. 스위프트 코드의 간결성은 자연스럽게 반복적으로 재사용하는 코드(boilerplate)를 줄이는 기능과 강한 타입 시스템의 부수효과로 드러날 뿐이다.

@lattner
lattner / async_swift_proposal.md
Last active February 23, 2024 11:41 — forked from oleganza/async_swift_proposal.md
Concrete proposal for async semantics in Swift

Async/Await for Swift

Introduction

Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.

This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.