Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Swift 周報 4/12
Search
Johnlin
April 12, 2016
Programming
0
86
Swift 周報 4/12
Swift 周報 4/12
Johnlin
April 12, 2016
Tweet
Share
More Decks by Johnlin
See All by Johnlin
用 MLIR 實作 一個 Ruby IR (intermediate representation)
johnlinvc
0
75
Unearth Ruby builtin Gems 發掘 Ruby 的內建 Gems
johnlinvc
0
210
Ruby 型別檢查工具簡介
johnlinvc
0
410
Swift Actor 實作探索
johnlinvc
0
140
用 mruby 來寫跨平台工具
johnlinvc
0
63
Actor model 簡介
johnlinvc
0
170
一起玩 Helm 3
johnlinvc
1
100
為什麼 App 卡卡的
johnlinvc
2
1.1k
如何使用 byebug 來除錯 Ruby 程式
johnlinvc
0
180
Other Decks in Programming
See All in Programming
[JAWS-UG横浜 #79] re:Invent 2024 の DB アップデートは Multi-Region!
maroon1st
1
140
Amazon Bedrock Multi Agentsを試してきた
tm2
1
280
SRE、開発、QAが協業して挑んだリリースプロセス改革@SRE Kaigi 2025
nealle
3
4.1k
昭和の職場からアジャイルの世界へ
kumagoro95
1
350
ASP. NET CoreにおけるWebAPIの最新情報
tomokusaba
0
360
Compose でデザインと実装の差異を減らすための取り組み
oidy
1
300
パスキーのすべて ── 導入・UX設計・実装の紹介 / 20250213 パスキー開発者の集い
kuralab
3
670
Writing documentation can be fun with plugin system
okuramasafumi
0
120
なぜイベント駆動が必要なのか - CQRS/ESで解く複雑系システムの課題 -
j5ik2o
7
2.5k
sappoRo.R #12 初心者セッション
kosugitti
0
230
DROBEの生成AI活用事例 with AWS
ippey
0
130
JavaScriptツール群「UnJS」を5分で一気に駆け巡る!
k1tikurisu
10
1.8k
Featured
See All Featured
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
A better future with KSS
kneath
238
17k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.4k
Building an army of robots
kneath
302
45k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Fireside Chat
paigeccino
34
3.2k
Reflections from 52 weeks, 52 projects
jeffersonlam
348
20k
Faster Mobile Websites
deanohume
306
31k
Done Done
chrislema
182
16k
Facilitating Awesome Meetings
lara
51
6.2k
Gamification - CAS2011
davidbonilla
80
5.1k
Code Reviewing Like a Champion
maltzj
521
39k
Transcript
Swift पใ 4/12 John Lin @johnlinvc
From the core • inliner ࠷ՂԽᩋࣥߦ䈕େখݮগ
inliner ࠷ՂԽᩋࣥߦ䈕େখݮগ • ࠷ՂԽ inliner ԋࢉ๏ᩋࣥߦ䈕େখݮগ • stdlib: 3% •
Benchmarks_O: 9% • ၷݸେఔࣜ: 15%, 20%
Evolution • SE-0042 ἷฏԽ instance method references తܕผ • SE-0043
ࡏ༗ଟݸpatterns త case label தએࠂᏓ Ꮠ • SE-0044 Import C function ᗣ swift function • SE-0047 ༬ઃܯࠂᔒ༗༻౸తճၚᆴ
ἷฏԽ instance method references తܕผ • ݱࡏ class Foo {
func foo(bar:Int) { print(bar) } } Foo.foo(Foo())(3) // 3 • ະိ Foo.foo(Foo(),3) // 3
ࡏ༗ଟݸpatterns త case label தએࠂᏓᏐ • Լ໘Ҏޙ။ಈ let point =
(2,2) switch point { case let (1,x), let (2,x): //error print(x) default: break }
Import C function ᗣ swift function • ݱࡏimport C function
ޙ။Ꮣglobal function • ະိՄҎࢦఆimport ਐိޙతҐஔɼबੋՄҎࢦఆC function ᗣ init, method, computed property, static property, static computed property ҃ੋ subscript • ༻ __attribute__((swift_name(“SWIFT_NAME")));
Import C function ᗣ swift function // Import as init
struct Point3D createPoint3D(float x, float y, float z) __attribute__((swift_name("Point3D.init(x:y:z:)"))); // Import as method struct Point3D rotatePoint3D(Point3D point, float radians) __attribute__((swift_name("Point3D.rotate(self:radians:)")));
༬ઃܯࠂᔒ༗༻౸తճၚᆴ • ᙛfunc ༗ճၚᆴɼୠੋᔒ༗ඃ༻౸త࣌ީሡ။༬ઃग़ݱܯࠂ func getScore()->Int { return 56 }
var score = 0 getScore() //will raise warning print(score) • ݱࡏ༬ઃෆ။ܯࠂɼ༻@warn_unused_result ՄҎ㗞ੜܯ ࠂɻ • ະိ༬ઃܯࠂɼՄҎ༻@discardableResult ိऔফܯࠂɻ
Evolution • SE-0016 Unsafe[Mutable]Pointer ՄҎ Int • SE-0053 function ჩᏐதෆ࠶ՄҎ༗
let • SE-0054 Abolish ImplicitlyUnwrappedOptional type • SE-0055 ᩋUnsafe Pointer༻Optional ိදࣔ nullability
Unsafe[Mutable]Pointer ՄҎ [U]Int • ՄҎPointer Int ೭ޙ၏֤छӡࢉɻ • ᩋSwift
ՄҎ၏ߋଟతܥ౷ఔࣜ
function ჩᏐதෆ࠶ՄҎ༗ let • function ჩᏐલpass by value ޙੋෆೳվᏓతɼະ ိ။શෆೳࡏჩᏐલ໘ଧ
let/var fun fLet(let a:Int) { print(a) } • ႔ɿະိ argument label ՄҎੋԿ keyword func fc(let l:Int) { print(l) } fc(let: 10)
ᩋUnsafe Pointer༻Optional ိ දࣔ nullability • ݱࡏᔒ༗㭎๏ኺType ग़Pointer ༗ᔒ༗Մೳੋ NULL
• ະိ Pointer ။Ճೖ Optional తޭೳ • if let ptr = nil_ptr { foo(ptr) }