Swift struct Presenter { var order: Int var name: String } var p = Presenter(order: 2, name: "ikesyo") p[keyPath: \Presenter.order] // 2 p[keyPath: \Presenter.name] = "ా ᠳ" 14
0 // NOT A CONFLICT. These two accesses to 'x' are both reads. // Each completes instantaneously, so the accesses do not overlap and // therefore do not conflict. Even if they were not instantaneous, they // are both reads and therefore do no conflict. let z = x + x // NOT A CONFLICT. The right-hand side of the assignment is a read of // 'x' which completes instantaneously. The assignment is a write to 'x' // which completes instantaneously. The accesses do not overlap and // therefore do not conflict. x = x 19
side is a read of 'x' which completes // instantaneously. Calling the operator involves passing 'x' as an inout // argument; this is a write access for the duration of the call, but it does // not begin until immediately before the call, after the right-hand side is // fully evaluated. Therefore the accesses do not overlap and do not conflict. x += x // CONFLICT. Passing 'x' as an inout argument is a write access for the // duration of the call. Passing the same variable twice means performing // two overlapping write accesses to that variable, which therefore conflict. swap(&x, &x) 20
function: () -> Int) { self = function() } } // CONFLICT. Calling a mutating method on a value type is a write access // that lasts for the duration of the method. The read of 'x' in the closure // is evaluated while the method is executing, which means it overlaps // the method's formal access to 'x'. Therefore these accesses conflict. x.assignResultOf { x + 1 } 21
on associated types // Will not currently compile protocol Sequence { associatedtype SubSequence: Sequence where Iterator.Element == SubSequence.Iterator.Element, SubSequence.SubSequence == SubSequence // Returns a subsequence containing all but the first 'n' items // in the original sequence. func dropFirst(_ n: Int) -> Self.SubSequence // ... } 26
Primary Focus: ABI Stability • Swift ABI Stability Manifesto • ABI Dashboard • Generics features needed for standard library, API resilience, Memory ownership model (carried over from Swift 4) 29
of the most important fundamental types in the language. The standard library leads have numerous ideas of how to improve the programming model for it, without jeopardizing the goals of providing a unicode-correct-by-default model. Our goal is to be better at string processing than Perl! 32