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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
170
Swift Attributes
hokuron
0
460
Peek in Calendar implementation of swift-foundation
hokuron
0
240
MVVM
hokuron
0
72
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
70
Clean Architecture 2
hokuron
0
87
Other Decks in Programming
See All in Programming
Making the RBS Parser Faster
soutaro
0
700
PHPでローカル環境用のSSL/TLS証明書を発行することはできるのか? #phpconkagawa
akase244
0
360
開発とはなにか、Essenceカーネルで見えるもの
ukin0k0
0
140
Firefoxにコントリビューションして得られた学び
ken7253
2
160
属人化しないコード品質の作り方_2026.04.07.pdf
muraaano
0
340
20260514_its_the_context_window_stupid.pdf
heita
0
920
My daily life on Ruby
a_matsuda
3
280
Agent Skills を社内で育てる仕組み作り
jackchuka
1
1.9k
How We Benchmarked Quarkus: Patterns and anti-patterns
hollycummins
1
190
【ディップ|26年新卒研修資料】TDD実装演習
dip_tech
PRO
0
180
(Re)make Regexp in Ruby: Democratizing internals for the JIT
makenowjust
3
1k
Import assertionsが消えた日~ECMAScriptの仕様はどう決まり、なぜ覆るのか~
bicstone
2
180
Featured
See All Featured
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
130
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
エンジニアに許された特別な時間の終わり
watany
106
240k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
3.9k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
65
54k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
740
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Bash Introduction
62gerente
615
210k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.2k
Between Models and Reality
mayunak
3
290
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.7k
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