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
bel lispの紹介
Search
Niyarin
July 29, 2021
Technology
0
690
bel lispの紹介
Niyarin
July 29, 2021
Tweet
Share
More Decks by Niyarin
See All by Niyarin
Scheme用nREPLの開発(エラー出力の改善)
niyarin
0
140
nanopass-compiler-frameworkを使ってみました
niyarin
0
410
Gorgos-parser-combinator-written-in-scheme
niyarin
0
370
outputting-beautiful-s-expression
niyarin
0
360
Serialisp
niyarin
1
640
Mongo DBとS式検索
niyarin
0
290
goodbye-python-repl
niyarin
0
340
SchemeのEphemeronとWeak Pairの説明
niyarin
0
950
red-paren-scheme-rev-macro.pdf
niyarin
0
390
Other Decks in Technology
See All in Technology
新卒エンジニア研修の試行錯誤と工夫/nikkei-tech-talk-31
nishiuma
0
150
コミュニティとおかねの話 / Community and Money
kgsi
0
100
目次機能実装から理解するLexical Editor
wtdlee
0
130
17年のQA経験が導いたスクラムマスターへの道 / 17 Years in QA to Scrum Master
toma_sm
0
180
Explainable Software Engineering in the Public Sector
avandeursen
0
280
Vision Language Modelを活用した メルカリの類似画像レコメンドの性能改善
yadayuki
9
1k
KCD Brazil '25: Enabling Developers with Dapr & Backstage
salaboy
1
110
移行できそうでやりきれなかった 10年超えのシステムを葬るための戦略
ryu955
2
180
View Transition API
shirakaba
1
830
3/26 クラウド食堂LT #2 GenU案件を通して学んだ教訓 登壇資料
ymae
1
120
PostgreSQL Unconference #52 pg_tde
nori_shinoda
0
120
Go の analysis パッケージで自作するリファクタリングツール
kworkdev
PRO
1
340
Featured
See All Featured
What's in a price? How to price your products and services
michaelherold
244
12k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
50
2.4k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
117
51k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
Agile that works and the tools we love
rasmusluckow
328
21k
Practical Orchestrator
shlominoach
186
10k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
14
1.1k
Automating Front-end Workflow
addyosmani
1369
200k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
8
690
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.6k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7.1k
Transcript
(いまさら) Belについて 簡単な紹介と処理系 Niyarin
Belとは Paul Graham氏のLisp系言語 データの種類が少ない ・Symbol, Pair, Char ,Stream ・他のありがちなデータもこれらで表現 コンパクトだが、継続やマクロがちゃんとある
・実装はたのしめると思う レキシカルスコープ、lisp-1 公式は処理系を出していない ・ただし、コアの部分さえ実装すれば動かせる ・残りの部分はbel.belとして提供されている
せっかくなのでArcについても (Wikipedia程度の情報) Paul Graham氏のLisp系言語 Belの前に開発されていた 実用的に使われた実績がある Hacker Newsのweb formとフィード (今はどうなのか不明)
Arcのフォーラム Racketで実装 コアが小さい (bel同様)
Belを読む (http://www.paulgraham.com/bel.html) bellanguage.txt belのコア言語の”カジュアル”な定義 bel.bel 拡張関数、マクロや数値の定義 belexamples.txt ちょっとの例
Belと既存のLispの慣習 ・ 空リストはnil。偽でもある。ただし、nilはシンボル ・非真性list有り ・ car, cdrはそのまま。 ペアの変更は、xar, xdr ・condがない
代わりに、 (if a1 a2 a3 a4 … an) ・ lisp1、レキシカルスコープ ・伝統的macro (風)
Belのデータ表現1 / 3 関数もリスト こんな表現 (lit clo ローカル環境 引数 本体)
・ closureを作る構文は、quasiquoteで書かれている ・ 例 ((lit clo nil (x) (+ x 1)) 100) → 101 ⚠ lit構文は、自身をそのまま返す
Belのデータ表現2 / 3 マクロもリスト 表現 (lit mac クロージャ) よくある、クロージャに式を渡して展開する やつ
(クロージャ 式) eval→ 展開結果 eval→ 実行結果
Belのデータ表現3 / 3 その他 数値もリスト 0,1,2,3,4 ... → nil, (t), (t
t), (t t t), (t t t t) … 文字列もリスト “abc” → (\a \b \c) 空リストと”真”はシンボル nil t
継続もある ・ ccc”構文”で作れる ・もちろん継続もリスト 表現の形式は実装者依存 niyarinは、 (lit cont コールスタック ローカル環境)
⚠ インタプリタのコールスタックを陽で持っておく ・dynamic-wind風の構文、afterもある 継続で外への脱出を検出し、その前に指定した処理を実行させ る
Belで実用的なコードを書けるのか? がんばればいける ・ (coin) 関数 ランダムで t , nil を出す
・ (sys <string>) 関数 <string>の内容をOSに実行させる ・ (thead x) 構文 xを評価する新しいスレッドを作る ・ IO streamデータがある。ただし、バイナリしか読めない
Belは処理系実装の題材としては良い 評価器はコンパクト 4種のデータと16個の関数と9個のsyntax quasiquote bel.belを実行するためのいくつかのsyntax-sugar 処理系実装が楽しめる要素 マクロ、継続、継続の捕捉、動的束縛、quasiquote 題材は良いが、テキストの抜けを自力で埋める必要がある
実装 ・ bel-sml (github.com/niyarin/bel-sml) niyarinの”未完成”の実装 Standard MLで書かれた素朴なインタプリタ 気合をいれればすぐできそうだが、さぼってました ・他の人の実装 ほとんどインタプリタ
(ぱっと見、それ以外は発見できず) luksamuk/believe (C), masak/bel (Perl), ajlopez/beljs (JS) cookrn/babybel(Ruby) ,
その他実装 IGJoshua/skitter (Clojure) bel-likeと謳っているが何が違うのだろう BranislavLazic/bell lが一個多かった。別言語だったよ (Lispだったけど)
おしまい まとめ Belはコンパクトで自己記述がおもしろい言語 継続とかあって実装は楽しい 公式の実装はないけど、実装はたくさんある