aboutsummaryrefslogtreecommitdiff
path: root/go/src/types
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-10-06 21:03:03 -0500
committerJoel Martin <github@martintribe.org>2014-10-06 21:03:03 -0500
commit17e1c5f9f4006399398e8bb7e219a79962ebf3f0 (patch)
treecb7de0111d91c56ae61ee500a2798264773cf54b /go/src/types
parentaf8fdff41e260b1b21be0e127afb536980f43804 (diff)
downloadmal-17e1c5f9f4006399398e8bb7e219a79962ebf3f0.tar.gz
mal-17e1c5f9f4006399398e8bb7e219a79962ebf3f0.zip
go: add step5_tco. Refactor env.
Move EnvType interface definition to types.go. Remove Env pointers.
Diffstat (limited to 'go/src/types')
-rw-r--r--go/src/types/types.go46
1 files changed, 35 insertions, 11 deletions
diff --git a/go/src/types/types.go b/go/src/types/types.go
index 95bdc1f..f0ab427 100644
--- a/go/src/types/types.go
+++ b/go/src/types/types.go
@@ -6,34 +6,54 @@ import (
//"fmt"
)
-//type Error interface {
-// error
-//}
+//import (
+// "env"
+//)
type MalType interface {
}
+type EnvType interface {
+ //Find(key string) *EnvType
+ Find(key string) EnvType
+ Set(key string, value MalType) MalType
+ Get(key string) (MalType, error)
+}
+
+// Symbols
type Symbol struct {
Val string
}
-type List struct {
- Val []MalType
+func Symbol_Q(obj MalType) bool {
+ switch obj.(type) {
+ case Symbol: return true
+ default: return false
+ }
}
-type Vector struct {
- Val []MalType
+
+// Functions
+type MalFunc struct {
+ Eval func(MalType, EnvType) (MalType, error)
+ Exp MalType
+ Env EnvType
+ Params MalType
}
-// Symbols
-func Symbol_Q(obj MalType) bool {
+func MalFunc_Q(obj MalType) bool {
switch obj.(type) {
- case Symbol: return true
- default: return false
+ case MalFunc: return true
+ default: return false
}
}
+
// Lists
+type List struct {
+ Val []MalType
+}
+
func List_Q(obj MalType) bool {
switch obj.(type) {
case List: return true
@@ -42,6 +62,10 @@ func List_Q(obj MalType) bool {
}
// Vectors
+type Vector struct {
+ Val []MalType
+}
+
func Vector_Q(obj MalType) bool {
switch obj.(type) {
case Vector: return true