次の一手を考える - Scheme VM を書く
実装の優先順位を考える。
今はとにかく独り立ちが望まれるので Gauche で動いているコンパイラが VM で動くようにすることが当面の目標。
コンパイラで使用している構文を優先的に実装。
あとは、(read) 相当をどう実装するかだけど Gauche の read.c を何とか流用できないかと考えている。
確か SigScheme もそんなことをやっていたと思うので。
実装するもの
- ■unless
- ■not
- ■when
- ■
- ■>
- ■>=
- ■<=
- ■eq?
- ■or
- ■and
- ■list
- ■pair?
- ■symbol?
- □apply
- □find
- □quasi quote
- □fold-rignt
- □values
- □call-with-values
- □display
- □format
- □error
when
(when pred body) => (cond (pred body))
unless
when とほぼ同様
not
if への変換で書けるけど instruction にする。
accumulator が #f であれば #t にする。
and
if に変換。fold-rignt で一発。
or
(define (or->if sexp) (fold-right (lambda (a b) `(if ,a ,a ,b)) #f (cdr sexp)))
>, <, >=, <=
= 演算子と同じように実装。
eq?
This is the fastest and finest predicate. Returns #t if obj1 and obj2 are allocated objects of the same types, and denote the same location.
symbol?, pair?
accumulator にあるオブジェクトを判定して結果を accumulator に。