aboutsummaryrefslogtreecommitdiff
path: root/go/src/printer/printer.go
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-10-09 21:37:00 -0500
committerJoel Martin <github@martintribe.org>2014-10-09 21:37:00 -0500
commitf2544a9467ea032aff505b3ced3b4b3510a828fe (patch)
treeaa1984aef01c20b7b093527c28c37bd7d4d803d5 /go/src/printer/printer.go
parentf2c9811fd8cbb205fad68952ebc1ba5d310f148d (diff)
downloadmal-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/printer/printer.go')
-rw-r--r--go/src/printer/printer.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/go/src/printer/printer.go b/go/src/printer/printer.go
index 887c749..428958e 100644
--- a/go/src/printer/printer.go
+++ b/go/src/printer/printer.go
@@ -24,9 +24,9 @@ func Pr_str(obj types.MalType, print_readably bool) string {
return Pr_list(tobj.Val, print_readably, "(", ")", " ")
case types.Vector:
return Pr_list(tobj.Val, print_readably, "[", "]", " ")
- case map[string]types.MalType:
- str_list := make([]string, 0, len(tobj)*2)
- for k, v := range tobj {
+ case types.HashMap:
+ str_list := make([]string, 0, len(tobj.Val)*2)
+ for k, v := range tobj.Val {
str_list = append(str_list, Pr_str(k, print_readably))
str_list = append(str_list, Pr_str(v, print_readably))
}
@@ -51,6 +51,9 @@ func Pr_str(obj types.MalType, print_readably bool) string {
Pr_str(tobj.Exp, true) + ")"
case func([]types.MalType)(types.MalType, error):
return fmt.Sprintf("<function %v>", obj)
+ case *types.Atom:
+ return "(atom " +
+ Pr_str(tobj.Val, true) + ")"
default:
return fmt.Sprintf("%v", obj)
}