tiancaiamao / shen-go

A Go implementation of the Shen programming language
Other
55 stars 4 forks source link

*: use cora to implement klambda, remove the `Evaluator` interface #22

Closed tiancaiamao closed 3 years ago

tiancaiamao commented 3 years ago

The Evaluator is introduced because the eval() method is different between cora and shen. Now I realize that klambda can be implemented by cora.

The sementic of a symbol:

symbol => (quote symbol)

Dual namespace problem:

(f xxx) => ((ns2-value f) xxx)
(defun f ...) => (ns2-set f ...)
(set sym val) => (ns3-set sym val)
(value sym) => (ns3-value sym)

or and cond ... can be implemented with macros

trap-error can also be a macro and implement by the 'try-catch' primitive:

(trap-error Exp (lambda E ...)) => (try-catch (lambda () Exp) (lambda (E) ...))