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
94
0
Share
Swift 周報 4/12
Swift 周報 4/12
Johnlin
April 12, 2016
More Decks by Johnlin
See All by Johnlin
用 MLIR 實作 一個 Ruby IR (intermediate representation)
johnlinvc
0
260
Unearth Ruby builtin Gems 發掘 Ruby 的內建 Gems
johnlinvc
0
340
Ruby 型別檢查工具簡介
johnlinvc
0
570
Swift Actor 實作探索
johnlinvc
0
190
用 mruby 來寫跨平台工具
johnlinvc
0
110
Actor model 簡介
johnlinvc
0
230
一起玩 Helm 3
johnlinvc
1
150
為什麼 App 卡卡的
johnlinvc
2
1.3k
如何使用 byebug 來除錯 Ruby 程式
johnlinvc
0
240
Other Decks in Programming
See All in Programming
第3木曜LT会 #28
tinykitten
PRO
0
110
The Monolith Strikes Back: Why AI Agents ❤️ Rails Monoliths
serradura
0
340
JOAI2026 1st solution - heron0519 -
heron0519
0
140
〜バイブコーディングを超えて〜 チームで実験し続けたAI駆動開発
tigertora7571
0
140
ドメインイベントでビジネスロジックを解きほぐす #phpcon_odawara
kajitack
3
790
おれのAgentic Coding 2026/03
tsukasagr
1
150
ソフトウェア設計の結合バランス #phperkaigi
kajitack
0
140
AI時代のPhpStorm最新事情 #phpcon_odawara
yusuke
0
190
「話せることがない」を乗り越える 〜日常業務から登壇テーマをつくる思考法〜
shoheimitani
4
830
Liberating Ruby's Parser from Lexer Hacks
ydah
2
1.7k
PHP で mp3 プレイヤーを実装しよう
m3m0r7
PRO
0
280
Server-Side Kotlin LT大会 vol.18 [Kotlin-lspの最新情報と Neovimのlsp設定例]
yasunori0418
1
170
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
Typedesign – Prime Four
hannesfritz
42
3k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.1k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
150
Design in an AI World
tapps
1
200
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Deep Space Network (abreviated)
tonyrice
0
120
A designer walks into a library…
pauljervisheath
211
24k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.6k
Heart Work Chapter 1 - Part 1
lfama
PRO
6
35k
Designing Powerful Visuals for Engaging Learning
tmiket
1
350
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
220
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) }