Slide 1

Slide 1 text

4XJGU.BDSPʹඋ͑ͯ 
 ߏจ໦ΛNJOͰֶͿ Kuniwak - DeNA Co.,Ltd. 2023.08.24 SwiftWednesday

Slide 2

Slide 2 text

"CPVUNF

Slide 3

Slide 3 text

,VOJXBL w ॴଐˠ w 4XJGU4ZOTUBYʹ 
 DPOUSJCVUFͨ͜͠ͱ͋Δ w ࠷ۙJ04ΞϓϦॻ͍ͯͳ͍ w "QQ$PEF͸͍͍ͧʢྦʣ 3

Slide 4

Slide 4 text

෼ؒͰ఻͍͑ͨ͜ͱ

Slide 5

Slide 5 text

ߏจ໦ͱ͸ίʔυΛѻ͍΍͍͢ 
 σʔλ΁ม׵ͨ͠΋ͷͰ͋Δ ߏจ໦͸ා͘ͳ͍ՄѪ͍Α 5

Slide 6

Slide 6 text

4XJGU.BDSPͱ͸

Slide 7

Slide 7 text

4XJGUʹ.BDSP͕΍͖ͬͯͨ 4XJGU͔Β࢖͑Δ 7

Slide 8

Slide 8 text

8 ࢖͑Δ.BDSP͸࣍ͷͭɿ w 'SFFTUBOEJOH.BDSP w "UUBDIFE.BDSP

Slide 9

Slide 9 text

9 @OptionSet struct Permissions { private enum Perm: Int { case read case write case execute 
 } } struct Permissions { private enum Perm: Int { case read case write case execute 
 } static let read: Self = 
 Self(rawValue: 1 << Perm.rea 
 static let write: Self = 
 Self(rawValue: 1 << Perm.wri 
 static let execute: Self = 
 Self(rawValue: 1 << Perm.exe } "UUBDIFE.BDSPͷྫ Attached macro ల։

Slide 10

Slide 10 text

͍ͣΕʹ΋ڞ௨͢Δͷ͸ߏจ໦͔Β 
 ߏจ໦΁ͷม׵Ͱ͋Δͱ͍͏͜ͱ 10 ʁ ʁ ߏจ໦ ߏจ໦ ϚΫϩల։

Slide 11

Slide 11 text

ߏจ໦͕Կ͔Λ஌Βͳ͍ͱ࡞Εͳ͍ 11 ʁ ʁ ߏจ໦ ߏจ໦ ϚΫϩల։

Slide 12

Slide 12 text

ߏจ໦ͱ͸Կ͔

Slide 13

Slide 13 text

if let self = self {} 13 આ໌ʹ࢖͏αϯϓϧίʔυ

Slide 14

Slide 14 text

if let self = self {} JGจ 14 ͜Ε͸ʮJGจʯͱݺ͹ΕΔ

Slide 15

Slide 15 text

if let self = self {} if let self = self {} JGจ ෳจ ৚݅ 15 JGจ͸ʮ৚݅ʯͱʮෳจʯͰ 
 ߏ੒͞Ε͍ͯΔ

Slide 16

Slide 16 text

if let self = self {} if let self = self {} JGจ ෳจ 0QUJPOଋറ৚݅ 16 ࠓճͷ৚݅෦෼ʹ͸ɺ 
 ʮ0QUJPOଋറ৚݅ʯͱ 
 ݺ͹Ε͍ͯΔ΋ͷ͕ೖΔ

Slide 17

Slide 17 text

if let self = self {} if let self = self {} JGจ ෳจ 0QUJPOଋറ৚݅ ม਺ࣜ ม਺ύλʔϯ if let self = self {} 17 0QUJPOଋറ৚݅͸ɺ୅ೖઌͷ 
 ʮม਺ύλʔϯʯͱ୅ೖ͢Δ஋ͷ 
 ʮม਺ࣜʯͰߏ੒͞Ε͍ͯΔ

Slide 18

Slide 18 text

if let self = self {} if let self = self {} if let self = self {} 18 ͜ͷΑ͏ʹɺίʔυΛ෼ղͯ͠ 
 ߏ੒ཁૉΛḷ͍ͬͯ͘ͱɺ 
 ίʔυΛʮ໦ߏ଄ʯͱͯ͠ 
 ѻ͍ͬͯΔ͜ͱʹؾͮ͘

Slide 19

Slide 19 text

19 ෳจ JGจ ෳจ ม਺ύλʔϯ ม਺ࣜ 0QUJPOଋറ৚݅ if let self = self {} if let self = self {} if let self = self {}

Slide 20

Slide 20 text

20 ෳจ JGจ ෳจ ม਺ύλʔϯ ม਺ࣜ 0QUJPOଋറ৚݅ ͜ΕΛʮߏจ໦ʯͱΑͿ if let self = self {} if let self = self {} if let self = self {}

Slide 21

Slide 21 text

4XJGU.BDSPͷதͰ ߏจ໦͕Ͳ͏ಇ͔͘

Slide 22

Slide 22 text

22 TUSVDUએݴ 1FSNJTTJPOT FOVNએݴ 1FSN $BTFએݴ $BTFએݴ $BTFએݴ SFBE XSJUF FYFDVUF ղੳ @OptionSet struct Permissions { private enum Perm: Int { case read case write case execute 
 } }

Slide 23

Slide 23 text

23 TUSVDUએݴ 1FSNJTTJPOT FOVNએݴ 1FSN $BTFએݴ $BTFએݴ $BTFએݴ SFBE XSJUF FYFDVUF TUSVDUએݴ 1FSNJTTJPOT FOVNએݴ 1FSN $BTFએݴ $BTFએݴ $BTFએݴ SFBE XSJUF FYFDVUF ม਺એݴ ॳظԽઅ SFBE ม਺એݴ ॳظԽઅ XSJU ม਺એݴ ॳظԽઅ FYFD ௥Ճ มܗ ੳ

Slide 24

Slide 24 text

struct Permissions { private enum Perm: Int { case read case write case execute 
 } static let read: Self = 
 Self(rawValue: 1 << Perm.rea 
 static let write: Self = 
 Self(rawValue: 1 << Perm.wri 
 static let execute: Self = 
 Self(rawValue: 1 << Perm.exe } 24 TUSVDUએݴ 1FSNJTTJPOT FOVNએݴ 1FSN $BTFએݴ $BTFએݴ $BTFએݴ SFBE XSJUF FYFDVUF ม਺એݴ ॳظԽઅ SFBE ม਺એݴ ॳظԽઅ XSJU ม਺એݴ ॳظԽઅ FYFD ௥Ճ ௥Ճ ίʔυ ͱͯ͠ 
 ݟΔͱ มܗ

Slide 25

Slide 25 text

ߏจ໦ΛͲ͏΍ͬͯ 
 ֬ೝͰ͖Δ͔

Slide 26

Slide 26 text

4XJGU"45&YQMPSFSΛ࢖͏ͷָ͕ 26

Slide 27

Slide 27 text

27 https://swift-ast-explorer.com/

Slide 28

Slide 28 text

ߏจ໦͸Կʹ࢖͑Δͷ͔

Slide 29

Slide 29 text

ߏจ໦͸.BDSPҎ֎ʹ΋ 
 ͞·͟·ͳ͜ͱʹར༻Ͱ͖Δ 29

Slide 30

Slide 30 text

w ੩తղੳʢ-JOUʣ w ϑΥʔϚολ w ίʔυੜ੒ w FUD 30

Slide 31

Slide 31 text

͜ͷઈ޷ͷػձʹߏจ໦Λ 
 ֮͑ͯ͠·͍·͠ΐ͏ 31

Slide 32

Slide 32 text

4XJGUͷߏจ໦Λ஌ͬͯ 
 .BDSP͚ͩͰͳ͘ 
 ৭ʑͳ͜ͱʹ׆༻͠Α͏ ·ͱΊ 32