Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Golangで小さなLispインタプリタを作ってみた
Search
Takuro Niitsuma
December 25, 2017
Programming
220
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Golangで小さなLispインタプリタを作ってみた
昔の社内勉強会で作ったスライド。GitPitchが閉鎖してたため移行。
Takuro Niitsuma
December 25, 2017
More Decks by Takuro Niitsuma
See All by Takuro Niitsuma
ウェブ・ソーシャルメディア論文読み会 - Machine-Made Media: Monitoring the Mobilization of Machine-Generated Articles on Misinformation and Mainstream News Websites
otakumesi
0
160
Reactでライフゲームを作ってみた話
otakumesi
0
160
Other Decks in Programming
See All in Programming
残高管理から台帳サービスへの進化
artoy
1
200
機械に任せるテスト、人が見るテスト ⽣成AIで引き直した、運⽤保守フェーズの線引き
dske104
0
190
Domain-Driven Transformation
hschwentner
2
2.3k
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
280
自サークルのIdPからログアウトできるようになるまで
taiseiue
1
140
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
300
JIS keyboard support in Omarchy
lef237
0
130
複雑なUIコンポーネントとの ⻑い付き合い⽅:波及するバグからテスト戦略を経て、安全な再設計へ
mixplace
0
430
R8 の設定見直しでアプリサイズ削減
andpad
0
220
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
170
RAG の “R” を Swift で覗いてみる 〜「意味から探す」検索の仕組み〜
nao_randd
0
170
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
220
Featured
See All Featured
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
410
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.6k
Technical Leadership for Architectural Decision Making
baasie
3
600
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
How to train your dragon (web standard)
notwaldorf
96
6.9k
What the history of the web can teach us about the future of AI
inesmontani
PRO
2
740
Darren the Foodie - Storyboard
khoart
PRO
4
4k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5.3k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
31k
Transcript
Golangで 小さなLispインタプリタ を作ってみた 0x64物語 Reboot #09 @otakumesi
@otakumesi マッハバイトでエンジニアしてます。
みなさん、木といったらなにを思い浮かべますか?
クリスマスツリー、木構造、二分木、...
Lisp
Lisp カッコが多いとかで敬遠されがちな言語 マスコットキャラのLispエイリアンが可愛い Haskell共和国と戦争中らしい(某書によると) LISt Processorを略した名称に由来
Lispエイリアン
Lispの構文は木構造 簡単なLispのコードを見てみましょう。 (+ (* 1 (+ 3 4)) (- 5
(/ 10 5))) ;; => 10
Lispの構文は木構造 ちゃんとインデントをつけてみてみると、 木構造に見えてきませんか? (+ (* 1 (+ 3 4)) (-
5 (/ 10 5))) ;; => 10
Lispの構文は木構造 Lispの構文のS式はそのまま構文木になります (+ (*1 (+34)) (-5 (/105)));; =>10 + /
\ * - / \ / \ 1 + 5 ÷ / \ / \ 3 4 10 5
GolangでLispを 実装した話
動機 Golangで挑戦できるいい題材を探してた (元)Emacs使いとしての目標の一つだった 0x64物語のお題が「木」だった
デモ(REPL) https://github.com/otakumesi/lispon
最初の発想 「Lispは木構造なので、S式の頂点から要素を再帰的に評価していけば、葉までたどり着いて 結果を返せそう」
ゆるふわなクラス図
反省 初期実装を勢いで書いたため「純LISP」の仕様の確認が遅くなった そして「カッコがいっぱいあるだけでLispじゃなくね?」と気がついて、途中でそ れなりに書き直した 未だにLispの仕様がゆるふわ...... Compositeパターンを意識して書いたらもう少しキレイな設計になった気がする
開発中にGolangに対して思ったこと メソッドオーバーロード欲しい オプション引数欲しい (生粋のGopherさんにマサカリ投げられそう)
引き算された言語機能が欲しいと思うこともあったが... Golangを書いてるとなぜだか心地よくなってきて、そんなことどうでもよくなりました (?)
そして、Golangのオプション引数の解決策が面白くて好きです
オプション引数の代替 FunctionalOptionPatternを使って解決した type Option func(*Sexpr)error func Rhs(rhs Evaler)error { return
func(*Sexpr)error { return s.SetRhs(rhs) } } func NewSexpr(opts ...Option) { ... }
せっかくなのでHTMLを書いてみた
GolangでLispをテンプレートエンジンっぽく使って LambdaからHelloWorldした図(?)
これをツイートしたらmattnさんに、 こんなコメントを貰えたので僕は満足しました
終わり