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
Opaque Result Type in Swift with Rust
Search
Takuma Shimizu
March 27, 2019
Programming
180
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Opaque Result Type in Swift with Rust
Takuma Shimizu
March 27, 2019
More Decks by Takuma Shimizu
See All by Takuma Shimizu
RailsのValidatesをSwift Macrosで再現してみた
hokuron
0
180
Swift Attributes
hokuron
0
470
Peek in Calendar implementation of swift-foundation
hokuron
0
250
MVVM
hokuron
0
77
Summon Rust from Swift
hokuron
0
710
Generalized accessors
hokuron
0
89
Ownership of Swift as seen from iteration and Rust
hokuron
1
730
Clean Architecture 3
hokuron
0
71
Clean Architecture 2
hokuron
0
88
Other Decks in Programming
See All in Programming
プロパティの順序で型推論が壊れる!? TypeScript6.0の修正からContext-Sensitivityの仕組みを追う
bicstone
2
1.3k
Webフレームワークの ベンチマークについて
yusukebe
0
150
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
150
AutonomyとControlのあいだ:Graflowで記述するAIエージェント協調
myui
0
110
tsserverとは何だったのか、これからどうなるのか
nowaki28
1
460
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
180
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
250
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
1.8k
Copilot CLI の継戦能力を高める コンテキスト管理
nozomutu
1
1.2k
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
120
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
260
Lessons from Spec-Driven Development
simas
PRO
0
150
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Paper Plane (Part 1)
katiecoart
PRO
0
8.7k
BBQ
matthewcrist
89
10k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
130
Ruling the World: When Life Gets Gamed
codingconduct
0
250
Design in an AI World
tapps
1
230
Navigating Weather and Climate Data
rabernat
0
210
Un-Boring Meetings
codingconduct
0
310
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2k
My Coaching Mixtape
mlcsv
0
140
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
Color Theory Basics | Prateek | Gurzu
gurzu
0
360
Transcript
Opaque Result Type in Swift with Rust
『Swift 5.1 に導入されそうな Opaque Result Type と は何か』 https://qiita.com/koher/items/338d2f2d0c4731e35 08f
リバースジェネリクス 通常のジェネリクス func useAnimal<A: Animal>(_ animal: A) { animal.foo() }
メソッド名に型引数を宣言 引数で型変数を利用 呼び出し側が型引数に対応する具象型を決定
リバースジェネリクス リバースジェネリクス func makeAnimal() -> <A: Animal> A { return
Cat() } メソッドシグネチャの後に型引数を宣言 返却値の型が型変数 実装側が型引数に対応する具象型を決定
Opaque Result Type some Animal を 返却値の型として利用 → リバースジェネリクス メソッド引数として利用
→ 通常のジェネリクスと同義 !!????
ジェネリクス func useAnimal<A: Animal>(_ animal: A) ↓ 型システム的な表現にすると ∀ A.
(func(A: Animal) -> ()) Opaque type func useAnimal(_ animal: some Animal) ↓ 型システム的な表現にすると (∃ A. A: Animal) -> ()
∀ A. (func(A: Animal) -> ()) ターンエーガンダムみたいななんかよく分からん記号 が、メソッドの引数から返却値まで全体にかかってい る。 (∃
A. A: Animal) -> () カタカナの「ヨ」みたいななんかよく分からん記号 は、出現場所( メソッド引数) だけにかかっている。 A. A: Animal の部分は一致している
つまり ∀ A. (func(A: Animal) -> ()) ⇔ (∃ A.
A: Animal) -> () という関係が成り立つ。 メソッド引数として利用した場合、通常のジェネリク スと同義 → 同じではないが、同形をとる
なぜプロトコル型に パフォーマンス上のロスがあるのか
Demo with Rust