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!