aboutsummaryrefslogtreecommitdiff
path: root/go/src/step7_quote
diff options
context:
space:
mode:
Diffstat (limited to 'go/src/step7_quote')
-rw-r--r--go/src/step7_quote/step7_quote.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/go/src/step7_quote/step7_quote.go b/go/src/step7_quote/step7_quote.go
index 0877bbb..abf7b45 100644
--- a/go/src/step7_quote/step7_quote.go
+++ b/go/src/step7_quote/step7_quote.go
@@ -30,7 +30,7 @@ func is_pair(x MalType) bool {
func quasiquote(ast MalType) MalType {
if !is_pair(ast) {
- return List{[]MalType{Symbol{"quote"}, ast}}
+ return List{[]MalType{Symbol{"quote"}, ast},nil}
} else {
slc, _ := GetSlice(ast)
a0 := slc[0]
@@ -42,12 +42,12 @@ func quasiquote(ast MalType) MalType {
if Symbol_Q(a00) && (a00.(Symbol).Val == "splice-unquote") {
return List{[]MalType{Symbol{"concat"},
slc0[1],
- quasiquote(List{slc[1:]})}}
+ quasiquote(List{slc[1:],nil})},nil}
}
}
return List{[]MalType{Symbol{"cons"},
quasiquote(a0),
- quasiquote(List{slc[1:]})}}
+ quasiquote(List{slc[1:],nil})},nil}
}
}
@@ -62,7 +62,7 @@ func eval_ast(ast MalType, env EnvType) (MalType, error) {
if e != nil { return nil, e }
lst = append(lst, exp)
}
- return List{lst}, nil
+ return List{lst,nil}, nil
} else if Vector_Q(ast) {
lst := []MalType{}
for _, a := range ast.(Vector).Val {
@@ -70,11 +70,11 @@ func eval_ast(ast MalType, env EnvType) (MalType, error) {
if e != nil { return nil, e }
lst = append(lst, exp)
}
- return Vector{lst}, nil
+ return Vector{lst,nil}, nil
} else if HashMap_Q(ast) {
- m := ast.(map[string]MalType)
- new_hm := map[string]MalType{}
- for k, v := range m {
+ m := ast.(HashMap)
+ new_hm := HashMap{map[string]MalType{},nil}
+ for k, v := range m.Val {
ke, e1 := EVAL(k, env)
if e1 != nil { return nil, e1 }
if _, ok := ke.(string); !ok {
@@ -82,7 +82,7 @@ func eval_ast(ast MalType, env EnvType) (MalType, error) {
}
kv, e2 := EVAL(v, env)
if e2 != nil { return nil, e2 }
- new_hm[ke.(string)] = kv
+ new_hm.Val[ke.(string)] = kv
}
return new_hm, nil
} else {
@@ -138,7 +138,7 @@ func EVAL(ast MalType, env EnvType) (MalType, error) {
ast = quasiquote(a1)
case "do":
lst := ast.(List).Val
- _, e := eval_ast(List{lst[1:len(lst)-1]}, env)
+ _, e := eval_ast(List{lst[1:len(lst)-1],nil}, env)
if e != nil { return nil, e }
if len(lst) == 1 { return nil, nil }
ast = lst[len(lst)-1]
@@ -155,7 +155,7 @@ func EVAL(ast MalType, env EnvType) (MalType, error) {
ast = a2
}
case "fn*":
- fn := MalFunc{EVAL, a2, env, a1, false, NewEnv}
+ fn := MalFunc{EVAL, a2, env, a1, false, NewEnv, nil}
return fn, nil
default:
el, e := eval_ast(ast, env)
@@ -164,7 +164,7 @@ func EVAL(ast MalType, env EnvType) (MalType, error) {
if MalFunc_Q(f) {
fn := f.(MalFunc)
ast = fn.Exp
- env, e = NewEnv(fn.Env, fn.Params, List{el.(List).Val[1:]})
+ env, e = NewEnv(fn.Env, fn.Params, List{el.(List).Val[1:],nil})
if e != nil { return nil, e }
} else {
fn, ok := f.(func([]MalType)(MalType, error))
@@ -214,7 +214,7 @@ func main() {
for _,a := range os.Args[2:] {
args = append(args, a)
}
- repl_env.Set("*ARGV*", List{args})
+ repl_env.Set("*ARGV*", List{args,nil})
rep("(load-file \"" + os.Args[1] + "\")")
os.Exit(0)
}