aboutsummaryrefslogtreecommitdiff
path: root/miniMAL/types.json
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2015-02-16 01:50:04 -0600
committerJoel Martin <github@martintribe.org>2015-02-24 09:17:45 -0600
commit8cfab77665957e8b26935e2b1690f65585273a09 (patch)
tree618f09b70daef9e7f675df27d6daa7d9b75a1c84 /miniMAL/types.json
parentad28cf3cb19d91399c52149d798f6c6efb780a51 (diff)
downloadmal-8cfab77665957e8b26935e2b1690f65585273a09.tar.gz
mal-8cfab77665957e8b26935e2b1690f65585273a09.zip
miniMAL: self-hosting! Add atoms. Fix malfunc.
- refactor malfunc to use objects like others.
Diffstat (limited to 'miniMAL/types.json')
-rw-r--r--miniMAL/types.json44
1 files changed, 29 insertions, 15 deletions
diff --git a/miniMAL/types.json b/miniMAL/types.json
index 26c5ffe..f67683e 100644
--- a/miniMAL/types.json
+++ b/miniMAL/types.json
@@ -36,7 +36,16 @@
null]],
["keys", "obj"]],
"new-obj"]],
- ["throw", "clone of unsupported type"]]]]]],
+ ["if", ["malfunc?", "obj"],
+ ["let", ["new-obj", ["malfunc", ["get", "obj", ["`", "fn"]],
+ ["get", "obj", ["`", "ast"]],
+ ["get", "obj", ["`", "env"]],
+ ["get", "obj", ["`", "params"]]]],
+ ["do",
+ ["set", "new-obj", ["`", "macro?"], ["get", "obj", ["`", "macro?"]]],
+ ["set", "new-obj", ["`", "__meta__"], ["get", "obj", ["`", "__meta__"]]],
+ "new-obj"]],
+ ["throw", "clone of unsupported type"]]]]]]],
["def", "clone", ["fn", ["obj"],
["let", ["new-obj", ["_clone", "obj"]],
@@ -111,21 +120,26 @@
["def", "map?", ["fn", ["a"],
["isa", "a", "HashMap"]]],
-
+["def", "MalFunc", ["fn", [], null]],
["def", "malfunc", ["fn", ["fn", "ast", "env", "params"],
- ["hash-map", ["`", "type"], ["`", "MalFunc"],
- ["`", "fn"], "fn",
- ["`", "ast"], "ast",
- ["`", "env"], "env",
- ["`", "params"], "params",
- ["`", "macro?"], false]]],
-
-["def", "malfunc?", ["fn", ["obj"],
- ["if", ["=", "obj", null],
- false,
- ["if", ["=", ["`", "MalFunc"], ["get", "obj", ["`", "type"]]],
- true,
- false]]]],
+ ["assocs!", ["new", "MalFunc"],
+ ["list", ["`", "fn"], "fn",
+ ["`", "ast"], "ast",
+ ["`", "env"], "env",
+ ["`", "params"], "params",
+ ["`", "macro?"], false]]]],
+
+["def", "malfunc?", ["fn", ["a"],
+ ["isa", "a", "MalFunc"]]],
+
+["def", "Atom", ["fn", [], null]],
+["def", "atom", ["fn", ["a"],
+ ["let", ["atm", ["new", "Atom"]],
+ ["do",
+ ["set", "atm", ["`", "val"], "a"],
+ "atm"]]]],
+["def", "atom?", ["fn", ["a"],
+ ["isa", "a", "Atom"]]],
null
]