言語開発合宿で作成した、Scheme(的なもの)のjavascript実装です。
継続と末尾再帰最適化まで実装しました。継続のほうは本当に仕様を満足しているかどうか不安ですが。
マクロは、ありません
詳しい説明はblogのほうに。
quote ('expr) , dotted pair( (x . y) ) , comment( ;; ) etc is not supported.
1 (define x 100) x (set! x 200) (list 1 2 3) (quote (a b c)) (+ 1 2 3) (- 10 4) (if (< x 10) "x < 10" "x >= 10")
(define create-counter (lambda (count) (lambda () (set! count (+ count 1)) count))) (define incr1 (create-counter 0)) (define incr2 (create-counter 100)) (incr1) ;;1 (incr2) ;;101 (incr1) ;;2 (incr1) ;;3 (incr2) ;;102
(define cc 0) (list 1 2 (+ (call/cc (lambda (c) (set! cc c) 1)) 2)) ;;(1 2 3) cc ;; #<continuation> (cc 0) ;;(1 2 2) (cc 10) ;;(1 2 12) (cc 100) ;;(1 2 102)
(js-eval "alert") ;;returns alert function ((js-eval "alert") "hello!") ;;hello!
this scheme evaluator is based on RKent Dyvbig, Three implementation models for scheme
this program using these libraries:
source: GitHub:todesking/todescheme