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
Scheme_syntax_sugars.pdf
Search
Niyarin
June 28, 2019
240
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Scheme_syntax_sugars.pdf
Niyarin
June 28, 2019
More Decks by Niyarin
See All by Niyarin
Scheme用nREPLの開発(エラー出力の改善)
niyarin
0
190
bel lispの紹介
niyarin
0
790
nanopass-compiler-frameworkを使ってみました
niyarin
0
490
Gorgos-parser-combinator-written-in-scheme
niyarin
0
420
outputting-beautiful-s-expression
niyarin
0
420
Serialisp
niyarin
1
730
Mongo DBとS式検索
niyarin
0
360
goodbye-python-repl
niyarin
0
400
SchemeのEphemeronとWeak Pairの説明
niyarin
0
1.1k
Featured
See All Featured
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4.1k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.3k
Six Lessons from altMBA
skipperchong
29
4.4k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
2
3.7k
The Pragmatic Product Professional
lauravandoore
37
7.4k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
119
120k
Product Roadmaps are Hard
iamctodd
55
12k
Visualization
eitanlees
152
17k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.5k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
280
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
190
Transcript
Scheme/SRFIの syntax sugarの紹介 Niyarin
内容 ・SRFIとは ・Scheme のsyntax sugarの紹介 1
SRFI ・Scheme の拡張の仕様 ・RNRS(Schemeの標準仕様)にたまにマージされる ・内容はいろいろある ・データ構造 SRFI 69 (hash) SRFI113
(set) ・組み込みデータ構造の処理 SRFI 1 (reduce とか) SRFI 132 (sortとか) ・実用的なやつ SRFI64 (test suite) SRFI 106 (Socket) 2
Syntax Sugar ・S式やめる ・可読性があがる? ・初心者にはフレンドリー? ・”Being Popular” では ”I still
don't find prefix math expressions natural.” Paul Graham (前置記法による数式が自然であるとは思えない) 3
Curly-infix-expressions (SRFI 105) ・{}は拡張のために予約されている → {}を中間表現に使う ・あまりサポートする処理系は少ない Guile {n >
5} ;(> n 5) {a + b + c} ;(+ a b c) (read-enable 'curly-infix) 4
Curly-infix-expressions (SRFI 105) ・f(x)形式も使える ・演算子と手続きの区別はない {‘a cons ‘b} ;(cons ‘a
‘b) {+(1 2)};(+ 1 2) {cons (‘a ‘b)} ;(cons ‘a ‘b) 5
Curly-infix-expressions (SRFI 105) ・演算子の優先順位はない ・複数の演算子を混ぜたり、{}内が偶数個の場合 → 自分で$nfx$を定義してどうにかしてってことらしい {1 + {2 *
3}} ;(+ 1 (* 2 3)) (1 + 2 * 3);($nfx$ 1 + 2 * 3) 6
どちらが良いか? { f{n - 1}(x) } ((f (- n 1))
x) ・C式 ・S式 7
Indentation-sensitive syntax (SRFI 49) ・インデントで構造化する構文(I式) ・標準でサポートしている処理系はSagittariusくらい define fac x if
= x 0 1 * x fac - x 1 #!reader=srfi/:49 (import (srfi :49)) 8
Indentation-sensitive syntax (SRFI 49) ・S式との共存もできる ・括弧で囲うにはgroupを使う define (fac x) if
(= x 0) 1 * x fac (- x 1) quote group a b ;(quote ((a b))) 9
Wisp (SRFI 119) ・なんだこれ ・標準で使える処理系はない →WispのサイトにGuile用のコードがあるのでインストールする define : factorial n
__ if : zero? n ____ . 1 ____ * n : factorial (- n 1) display : factorial 5 newline 10
Wisp (SRFI 119) ルール let ;(let ((x 1) : x 1
; (y 2) y 2 ; (y 3)) body ; body) ・Colon”:” 行頭にある ▶ 下のインデントが閉じるまで、 それ以外 ▶ 行末まで define : f a ;(define (f a) + ; + a 1) a 1 ・ Dot “.” 引数(atom)を並べる list . 1 2 . 3 . 4 ;(list 1 2 3 4) list 1 2 3 ;エラー 4 ;(list (1 2) (3) (4)) 11
・Under score ”_” 空白と同じ HTML上の空白の扱いにより、インデントが消えたりすることへの対処 Wisp (SRFI 119) ルール +
1 2 ___ + 3 4 ____ + 5 6 12
t-expressions SRFI 110 その他(紹介だけ) let <* x $
cos $ f c *> ! dostuff x 13
括弧 ( ) を減らすと別の記号が増えます。 初心者向きかは微妙。 おしまい 14