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
Kotlinのリストのmap関数、自動生成されているって!
Search
RyotaMurohoshi
August 25, 2018
Technology
3
630
Kotlinのリストのmap関数、自動生成されているって!
2018年8月25日(土)のKotlin FestのLT資料です!
RyotaMurohoshi
August 25, 2018
Tweet
Share
More Decks by RyotaMurohoshi
See All by RyotaMurohoshi
Tilemapのアップデートについて
ryotamurohoshi
0
56
Unityの合同同人誌や合同商業誌を書いてる僕は感想やレビューや評価が欲しい
ryotamurohoshi
0
570
Unity 2021.1での Unityパッケージの名称変更について
ryotamurohoshi
0
770
Odin Validationはいいぞ!
ryotamurohoshi
2
1k
Tilemapはいいぞ!2020 〜すごいぞ、プロジェクト専用拡張Brush〜
ryotamurohoshi
0
2.4k
Unityでも、新しいC#
ryotamurohoshi
0
1.4k
Riderはいいぞ!
ryotamurohoshi
1
3.6k
Riderのススメ〜俺はRiderここが好き〜
ryotamurohoshi
1
2.6k
Unity開発者に伝えたい.NETのこと
ryotamurohoshi
4
38k
Other Decks in Technology
See All in Technology
Eight Engineering Unit 紹介資料
sansan33
PRO
0
6.2k
Oracle Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
3
270
製造業から学んだ「本質を守り現場に合わせるアジャイル実践」
kamitokusari
0
410
プロンプトエンジニアリングを超えて:自由と統制のあいだでつくる Platform × Context Engineering
yuriemori
0
170
Agentic AIが変革するAWSの開発・運用・セキュリティ ~Frontier Agentsを試してみた~ / Agentic AI transforms AWS development, operations, and security I tried Frontier Agents
yuj1osm
0
210
技術選定、下から見るか?横から見るか?
masakiokuda
0
180
Digitization部 紹介資料
sansan33
PRO
1
6.4k
First-Principles-of-Scrum
hiranabe
3
1.5k
Qiita Bash アドカレ LT #1
okaru
0
170
AWS re:Inventre:cap ~AmazonNova 2 Omniのワークショップを体験してきた~
nrinetcom
PRO
0
130
戰略轉變:從建構 AI 代理人到發展可擴展的技能生態系統
appleboy
0
180
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.5k
Featured
See All Featured
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.8k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
1
880
More Than Pixels: Becoming A User Experience Designer
marktimemedia
2
280
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
59
Statistics for Hackers
jakevdp
799
230k
Skip the Path - Find Your Career Trail
mkilby
0
38
Code Review Best Practice
trishagee
74
19k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
120
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
2
78
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.3k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
140
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
Transcript
Kotlinのリストのmap関数のコード 自動生成されてるって! @RyotaMurohoshi 2018/08/25(土) Kotlin Fest LT
Kotlin 1.3にて 符号なし整数値型が登場予定! ※現状はまだExperimental
ソースコードを覗いてみましょう! https://github.com/JetBrains/kotlin/tree/v1.3-M1/libraries/stdlib/unsigned/src/kotlin
UInt
UShort
None
ほぼ一緒じゃん! ※ ここチョイ笑いするとこですよ
ところでちょっと気になるコメントに 気が付きましたか?
UInt
拡大すると・・・
ここ!!!
符号なし整数値型のコード 自動生成されてる! ※ ここ「へー」っていうことですよ!
`kotlin/generators`ディレクトリの `builtins/generateBuiltIns.kt`をみてね! https://github.com/JetBrains/kotlin/blob/v1.3-M1/generators/builtins/arrayIterators.kt `ranges`や`iterator`も生成されているよ!
ところで、Kotlinのstdlib・・・
https://github.com/JetBrains/kotlin/tree/1.2.60/libraries/stdlib Standard LibraryのReadMeには・・・
https://github.com/JetBrains/kotlin/tree/1.2.60/libraries/stdlib Standard LibraryのReadMeには・・・
そう、stdlibにも自動生成されたコードが! ※ ここ「へー」っていうことですよ!
どんなコードが自動生成されている? みんながよく使うアレも自動生成されている!
これ!map拡張関数! みんなが大好きリストのmap関数!
map拡張関数の実装も・・・? https://github.com/JetBrains/kotlin/blob/1.2.60/libraries/stdlib/common/src/generated/_Collections.kt#L1217
こいつも自動生成!!! ※ ここみんなが大きな声で「へー」っていうことですよ!
そう、mapもfilterも 実は、自動生成されているんです! ※ ここ”も”みんなが大きな声で「へー」っていうことですよ!
kotlin/libraries/tools/kotlin-stdlib-gen https://github.com/JetBrains/kotlin/tree/v1.3-M1/libraries/tools/kotlin-stdlib-gen
kotlin/libraries/tools/kotlin-stdlib-gen https://github.com/JetBrains/kotlin/tree/v1.3-M1/libraries/tools/kotlin-stdlib-gen Kotlinでのコード生成に興味があったら、読んでみて! @DslMarkerも利用した、コードジェネレータDSL! KDocも、DSLでいい感じに作っている!
kotlin/libraries/tools/kotlin-stdlib-gen https://github.com/JetBrains/kotlin/tree/v1.3-M1/libraries/tools/kotlin-stdlib-gen • `src/generators/GenerateStandardLib.kt`がエントリポイント • `src/templates/dsl`以下に、DSLのためのクラス群がある • `src/templates`以下に、DSLを利用したメソッドを実際に生成するクラス群
まとめ • Kotlinのコード、自動生成されているよ! • `kotlin/generators/builtins` • `kotlin/libraries/tools/kotlin-stdlib-gen` • stdlibのコード、DSLやコードジェネレーターの参考になるよ! •
ドメインがKotlinだから、他の知識なしでも理解が!
詳しくはブログで!
2018/08/25(土) Kotlin Fest LT @RyotaMurohoshi リストのmap関数のコード 自動生成されてるって!
時間が余ったのでみなさん大きな声で 「へーーー!」 って言っください! リストのmap関数のコード 自動生成されてるって!
Kotlinかわいい!