One day after reading SICP, I interested in implement my own scheme interpriter for practice. A design of Gigue is based on scheme interpriter of SICP Chapter 4.
Gigue is not the metacircular evaluator, simple scheme interpriter written in Go.
go get github.com/suzuken/gigue
From examples/fold.scm,
(define (fold-right op initial sequence)
(if (null? sequence)
initial
(op (car sequence)
(fold-right op initial (cdr sequence)))))
(print (fold-right / 1 (list 1 2 3)))
and gigue examples/fold.scm
, then output 1.5
.
Gigue has REPL.
-> % ./gigue
> (define x 1)
> (define y 2)
> (load "examples/sum.scm")
> (print (sum x y))
3
+
,-
,*
,/
cons
,car
,cdr
,list
,cadr
,cdar
,cddr
,caaar
,caddr
,cdadr
,cddar
,cdddr
<
,>
,<=
,>=
define
,lambda
,if
,cond
,begin
null?
,list?
,symbol?
,string?
,eq?
load
MIT
Kenta Suzuki (a.k.a. suzuken)
Written in above, Gigue is based on the interpriter written in SICP Chapter 4. If you are not similar to scheme, you don't mind it. I think writing scheme interpriter in scheme - metacircular evaluator - is much simpler than written in Go or other language.
If you're not have enough time to read SICP, scm.go, a Scheme interpreter in Go, as in SICP and lis.py | De Babbelbox of Pieter Kelchtermans may be helpful for understanding what a scheme interpriter is. A minimal Scheme interpreter, as seen in lis.py and SICP is a minimal scheme interpriter (surprisingly only 250 lines) written in Go .
And I found some projects which implements scheme interpriter in Go.