Skip to content

Instantly share code, notes, and snippets.

View ianpartridge's full-sized avatar

Ian Partridge ianpartridge

  • IBM
  • UK
View GitHub Profile
@lattner
lattner / TaskConcurrencyManifesto.md
Last active May 7, 2024 09:05
Swift Concurrency Manifesto
@lattner
lattner / async_swift_proposal.md
Last active April 21, 2024 09:43 — 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.

@phausler
phausler / main.swift
Created May 19, 2017 02:05
Hashability via Codability
import Foundation
struct HashingSingleValueEncodingContainer : SingleValueEncodingContainer {
var owner: HashingEncoder
mutating func combineHash<T>(of element: T?) where T: Hashable {
if let elt = element {
owner.combine(elt, hash: elt.hashValue) { (other: Any) -> Bool in
if let otherValue = other as? T {
return elt == otherValue
@jt-nti
jt-nti / tjbot-notes.md
Last active June 26, 2017 12:21
TJ Bot notes

TJ Bot notes

Just a few notes in my quest to build a bot. It's worth reading Calling all Makers: Meet TJBot! if you've not already met TJ Bot!

I currently have a 3D print of the robot thanks to a friendly master inventor with a new toy. It needs a brain though!

Parts

Parts from The Pi Hut (other stores are available!)