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
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
160
Swift Attributes
hokuron
0
460
Peek in Calendar implementation of swift-foundation
hokuron
0
230
MVVM
hokuron
0
65
Summon Rust from Swift
hokuron
0
710
Generalized accessors
hokuron
0
88
Ownership of Swift as seen from iteration and Rust
hokuron
1
720
Clean Architecture 3
hokuron
0
69
Clean Architecture 2
hokuron
0
86
Other Decks in Programming
See All in Programming
PHPで TLSのプロトコルを実装してみるをもう一度しゃべりたい
higaki_program
0
190
SkillがSkillを生む:QA観点出しを自動化した
sontixyou
6
3.3k
一度始めたらやめられない開発効率向上術 / Findy あなたのdotfilesを教えて!
k0kubun
4
2.9k
それはエンジニアリングの糧である:AI開発のためにAIのOSSを開発する現場より / It serves as fuel for engineering: insights from the field of developing open-source AI for AI development.
nrslib
1
840
PHP で mp3 プレイヤーを実装しよう
m3m0r7
PRO
0
260
10 Tips of AWS ~Gen AI on AWS~
licux
5
330
iOS機能開発のAI環境と起きた変化
ryunakayama
0
180
事業会社でのセキュリティ長期インターンについて
masachikaura
0
250
KagglerがMixSeekを触ってみた
morim
0
370
CursorとClaudeCodeとCodexとOpenCodeを実際に比較してみた
terisuke
1
420
Coding at the Speed of Thought: The New Era of Symfony Docker
dunglas
0
4.8k
存在論的プログラミング: 時間と存在を記述する
koriym
5
870
Featured
See All Featured
The World Runs on Bad Software
bkeepers
PRO
72
12k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.5k
What's in a price? How to price your products and services
michaelherold
247
13k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
130
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
23k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.9k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
150
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.2k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
420
Build your cross-platform service in a week with App Engine
jlugia
234
18k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
199
73k
Context Engineering - Making Every Token Count
addyosmani
9
820
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