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
continuation_web_framework_scheme.pdf
Search
Niyarin
July 25, 2019
Programming
420
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
continuation_web_framework_scheme.pdf
Niyarin
July 25, 2019
More Decks by Niyarin
See All by Niyarin
Scheme用nREPLの開発(エラー出力の改善)
niyarin
0
190
bel lispの紹介
niyarin
0
800
nanopass-compiler-frameworkを使ってみました
niyarin
0
500
Gorgos-parser-combinator-written-in-scheme
niyarin
0
430
outputting-beautiful-s-expression
niyarin
0
430
Serialisp
niyarin
1
740
Mongo DBとS式検索
niyarin
0
360
goodbye-python-repl
niyarin
0
400
SchemeのEphemeronとWeak Pairの説明
niyarin
0
1.1k
Other Decks in Programming
See All in Programming
新人はどこまで自力でやり、どこからAIに頼るべきか/エンジニア育成に向き合う_先輩たちの悩みと知見共有会
toppan_digital_dev
1
540
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
810
in-process GraphQL のすすめ #ginzajs
izumin5210
4
1.5k
一参加者から『中の人』へ 〜全通PHPerがブースに立って学んだ、カンファレンスを100倍楽しむコツ〜
wp_daisuke
0
110
Flow は今どうなっているか
mizdra
PRO
0
870
ソフトウェアラスタライザ
fadis
1
780
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
410
新卒PdEのリアル
ryu1013
0
130
Press start. Python's next generation.
willingc
PRO
3
300
LLMは4年分のCompose移行を再現できるのか?実プロダクト279件のXMLで探る自動化の境界線
makun
0
350
{ Android | Kotlin } Gradle Plugin in 2026
ryunen344
1
270
「つくるAI」だけではバグは見つからない ~テストに必要な「見つけるAI」を分離させる戦略~
mfunaki
0
230
Featured
See All Featured
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.3k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Utilizing Notion as your number one productivity tool
mfonobong
4
570
Between Models and Reality
mayunak
4
440
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
The Invisible Side of Design
smashingmag
301
52k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
270
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
440
Designing for humans not robots
tammielis
254
26k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
510
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Transcript
継続と アプリケーション (Schemeのオレオレ・Toy・Webフレームワークの紹介) Niyarin
オレオレ・Toy・WebFrameworkを作っています ・継続ベース ・プロトタイプ/学習用なのでセキュリティ、その他はてきとう ・未完成 niyarin/oreore-toy-webframework-scm 継続ベースのWebフレームワークはそれなりにある GaucheのKahua Ypsilonのlunula RacketのWebFramework
etc. 1
継続とは(てきとう) 特徴 ・ジャンプ ・値を渡せる ・状態を保持 (+ 1 (call/cc (lambda (c)
(c 2))) 3) ;6 (define out-c #f) (+ 1 (call/cc (lambda (c) (set! out-c c) (c 2))) 3) (out-c 100) ;104 2
継続をWEBアプリケーションに使う1 ・セッションの保存 . . . リクエスト1 レスポンス1 リクエスト2 レスポンス2 クライアントA
サーバー クライアントA name Taro old 30 セッションデータ (let ((name “Taro”) (old 30)) (call/cc (lambda (cont) ;contにセッション情報をのせる body …))) 3
継続をWEBアプリケーションに使う2 ・ページの遷移 localhost:8080/piyo?a=1&b=2 ↓ (… (call/cc (lambda (piyo) (set!
piyo-page cont))) …);遷移先のページ (piyo;遷移時に継続を呼び出す ‘((a 1) (b 2))) 4
コード紹介1:継続を使うと自然な記述ができる (define (index-page param) (let loop ((uname "") (password
"")) (let ((loginpage-data (call/cc (lambda (cont) (render `(ログインページ )))))) (cond ((not (validation loginpage-data)) (loop (get ‘uname content) (get ‘password content))) (else (render `(OKページ)))))) sample/sample.scm(一部省略) (define (index param) (let loop () (let ((data (read))) (cond ((failure? data) (loop)) (else (display “OK”))))) 同じ構造のプログラム 5
(otw-render-view `(html (body (div (@ (style "color:#ff0000")) ,error-message) (form (@
(action ,(otw-generate-uri cont)) ;生成結果=> piyo?contid=1 (method "post")) (input (@ (type "text") (name "uname") (value ,uname))) (input (@ (type "password") (name "password"))) (input (@ (type "submit") (value "Submit")))))) コード紹介2:どのように継続を渡すのか ID-継続の組で管理して、IDのほうを渡している ※ URLにID埋め込んでいるが、セキュ リティ的には✗ =>継続ハイジャック 6
実装中バグらせた話 (define (index-page param) (let loop ((uname "") (password
"")) (let ((loginpage-data (call/cc (lambda (cont) (render `(ログインページ )))))) (cond ((not (validation loginpage-data)) (loop (get ‘uname content) (get ‘password content))) (else (render `(OKページ)))))) 1. 赤い部分で止める必要がある なにもしないと、青い領域に入る ・render内で大域脱出する ・限定継続ベースにするのも手 2. 2つは違うリクエストなので、レスポン スを出力するポートは別 ・レキシカルな場所(左だとparam)におく と継続に補足される(古いポートが参照さ れる) ・外でスレッド-portで管理している 7
・継続を使うとWebアプリケーションを自然にかける ・いつか正式にリリースしたい 終わり