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
88
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
120
Unearth Ruby builtin Gems 發掘 Ruby 的內建 Gems
johnlinvc
0
250
Ruby 型別檢查工具簡介
johnlinvc
0
460
Swift Actor 實作探索
johnlinvc
0
160
用 mruby 來寫跨平台工具
johnlinvc
0
71
Actor model 簡介
johnlinvc
0
190
一起玩 Helm 3
johnlinvc
1
110
為什麼 App 卡卡的
johnlinvc
2
1.2k
如何使用 byebug 來除錯 Ruby 程式
johnlinvc
0
200
Other Decks in Programming
See All in Programming
「ElixirでIoT!!」のこれまでとこれから
takasehideki
0
360
Go1.25からのGOMAXPROCS
kuro_kurorrr
1
660
イベントストーミングから始めるドメイン駆動設計
jgeem
4
840
F#で自在につくる静的ブログサイト - 関数型まつり2025
pizzacat83
0
300
Javaに鉄道指向プログラミング (Railway Oriented Pro gramming) のエッセンスを取り入れる/Bringing the Essence of Railway-Oriented Programming to Java
cocet33000
2
550
從零到一:搭建你的第一個 Observability 平台
blueswen
1
920
Datadog RUM 本番導入までの道
shinter61
1
280
AIコーディング道場勉強会#2 君(エンジニア)たちはどう生きるか
misakiotb
1
200
Elixir で IoT 開発、 Nerves なら簡単にできる!?
pojiro
1
140
CSC307 Lecture 17
javiergs
PRO
0
110
Perplexity Slack Botを作ってAI活用を進めた話 / AI Engineering Summit プレイベント
n3xem
0
660
機械学習って何? 5分で解説頑張ってみる
kuroneko2828
0
210
Featured
See All Featured
Navigating Team Friction
lara
186
15k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
228
22k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
161
15k
How to Ace a Technical Interview
jacobian
276
23k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
The World Runs on Bad Software
bkeepers
PRO
68
11k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
[RailsConf 2023] Rails as a piece of cake
palkan
55
5.6k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
130
19k
Scaling GitHub
holman
459
140k
Side Projects
sachag
455
42k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.8k
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) }