Preparing for Swift 5 Ownership
by
kotetu (kotetuco)
×
Copy
Open
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Slide 1
Slide 1 text
Preparing for Swift 5 Ownership <4XJGUͷ0XOFSTIJQʹඋ͑Δ>
Slide 2
Slide 2 text
Kuriyama Toru <܀ࢁప> iOS Engineer at Sansan app (iOS/Android) “Business card-based contact management” Twitter: @kotetuɹɹɹɹɹɹ Github: @kotetuco
Slide 3
Slide 3 text
OwnershipManifesto.md (in GitHub - apple/swift) ഉଞଇ4XJGUͰ࣮ࡁΈ (swift-evolution’s proposal : SE-0176) Ownership
Slide 4
Slide 4 text
ίϐʔࢀরʹର͢ΔΑΓࡉ੍͔͍ޚͷ࣮ݱ ΑΓߴͳύϑΥʔϚϯενϡʔχϯά͕Մೳʹ Feature1: Advanced memory management
Slide 5
Slide 5 text
Example (shared values) func distance(start: shared CGPoint, end: shared CGPoint) -> Double { ... } let result = distance(start: CGPoint(x: 0, y: 0), end: CGPoint(x: 10, y: 10))
Slide 6
Slide 6 text
Example (shared values) func distance(start: shared CGPoint, end: shared CGPoint) -> Double { ... } let result = distance(start: CGPoint(x: 0, y: 0), end: CGPoint(x: 10, y: 10)) not copied not copied
Slide 7
Slide 7 text
func distance(start: shared CGPoint, end: shared CGPoint) -> Double { ... } let result = distance(start: CGPoint(x: 0, y: 0), end: CGPoint(x: 10, y: 10)) Example (shared values) not copied read-only not copied read-only
Slide 8
Slide 8 text
Non-copyable types ίϐʔෆՄೳͳܕ ҉తͳίϐʔΛ੍ݶ͢Δ JavaͷAtomicBooleanͷΑ͏ͳදݱ͕Մೳʹ moveonly struct Array { ... }
Slide 9
Slide 9 text
͍͜ͳ͢ʹֶशίετ͕͔͔Δ ͳ͔ͳ͔ফ͑ͳ͍ίϯύΠϧΤϥʔ ઌൃͷRustͰֶशίετͷߴ͕͞՝ʹ Feature2: Ownership is not easy
Slide 10
Slide 10 text
OwnershipഉଞଇҎ֎ΦϓτΠϯػೳ SwiftͰOwnershipΛΒͳͯ͘ࢧোͳ͍ ͜Ε·Ͱͱಉ͡ॻ͖ํͰ0, RustͰOwnershipΛΒͳ͍ͱॻ͚ͳ͍ Feature3: Opt-in
Slide 11
Slide 11 text
Conclusions 1. ϝϞϦΞΫηείϐʔʹ͍ͭͯߴͳ੍ޚ ͕Ͱ͖Δ 2. ֶशίετ͕͔͔Δ 3. ͏͔Ͳ͏͔Λબ͢Δ͜ͱ͕Ͱ͖Δ
Slide 12
Slide 12 text
Referenced by • https://github.com/apple/swift/blob/master/docs/ OwnershipManifesto.md • https://github.com/apple/swift-evolution/blob/master/proposals/ 0176-enforce-exclusive-access-to-memory.md • https://qiita.com/omochimetaru/items/c5f0eabde516e4713367 • https://github.com/omochi/swift-ownership-jp/blob/master/ OwnershipManifesto.md • https://github.com/rust-lang/rust-roadmap
Slide 13
Slide 13 text
I hope you'll enjoy it !
Slide 14
Slide 14 text
Thanks!