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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
150
Reactでライフゲームを作ってみた話
otakumesi
0
160
Other Decks in Programming
See All in Programming
海上で動くGoサーバー: goroutineとchannelでさばく航行データストリーム
atsuki_seo
0
980
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
440
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
7
5.1k
App Intentsのビルドプロセスを支える技術
kntkymt
0
470
個人開発基盤をまるごとCloudflareに引っ越して爆速で総合的体験を向上させた話
tinykitten
0
210
AGENTS.md Is Not Enough:Build Skills, Don't Download Them
lx_t
0
130
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
1
320
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
140
SREの越境 / SRE Collaboration
y0hgi
2
290
手動確認はもう限界 〜XCUITestでCustom URL Schemeの遷移を起動種別ごとに自動テストする〜 / Testing Custom URL Schemes with XCUITest
otouto
0
360
アクセシビリティから考える情報設計
high_g_engineer
0
420
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
460
Featured
See All Featured
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
490
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
290
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
610
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
Designing for Performance
lara
611
70k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.6k
Bash Introduction
62gerente
615
220k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
3
3.8k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
250
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
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さんに、 こんなコメントを貰えたので僕は満足しました
終わり