Keep Calm and Type Erase On
summary
Defines a type as a classification of values and legal operations, distinguishes concrete vs abstract types, and shows reification by supplying type parameters. Demonstrates type erasure via an any Pokemon wrapper that lets protocol-with-associated-type values be stored but loses specific type info and adds heavy boilerplate. Notes lack of covariance in Swift, the associatedtype (typealias → associatedtype) change in Swift 2.2, and a production use in the open source library Reis wit Swift / Reese wit for Flux-style StoreSubscriber wiring.
AI-written summary · about
chapters (8)
- 0:00Introduction to type erasure
- 1:27Concrete vs. abstract types
- 2:54Type reification
- 5:23Generic protocol challenges
- 7:54Implementing type erasure
- 10:41Downsides and future outlook
- 12:45Talk recap
- 13:43Q&A session
related talks
08mThe Type Erasure Advantage
35mProtocols with Associated Types
40mLeveraging Swift’s Type System
12mFeatherweight Swift: A Core Calculus for Swift’s Type System
16mGenerics in Theory and Practice
29mAlgebraic Data Types in Swift
30mLeveraging Swift's Type System
40mSwift type inference is simple! Or is it?
