diff options
| author | Joel Martin <github@martintribe.org> | 2014-10-09 21:37:00 -0500 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2014-10-09 21:37:00 -0500 |
| commit | f2544a9467ea032aff505b3ced3b4b3510a828fe (patch) | |
| tree | aa1984aef01c20b7b093527c28c37bd7d4d803d5 /go/src/step6_file | |
| parent | f2c9811fd8cbb205fad68952ebc1ba5d310f148d (diff) | |
| download | mal-f2544a9467ea032aff505b3ced3b4b3510a828fe.tar.gz mal-f2544a9467ea032aff505b3ced3b4b3510a828fe.zip | |
go: add metadata and atoms. HashMap dedicated type.
HashMap needs a dedicated type now to be able to store the metadata.
Diffstat (limited to 'go/src/step6_file')
| -rw-r--r-- | go/src/step6_file/step6_file.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/go/src/step6_file/step6_file.go b/go/src/step6_file/step6_file.go index 912d932..51fe3cb 100644 --- a/go/src/step6_file/step6_file.go +++ b/go/src/step6_file/step6_file.go @@ -33,7 +33,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 { @@ -41,11 +41,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 { @@ -53,7 +53,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 { @@ -105,7 +105,7 @@ func EVAL(ast MalType, env EnvType) (MalType, error) { env = let_env 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] @@ -122,7 +122,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) @@ -131,7 +131,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)) @@ -181,7 +181,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) } |
