aboutsummaryrefslogtreecommitdiff
path: root/js/types.js
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-04-09 23:58:27 -0500
committerJoel Martin <github@martintribe.org>2014-04-09 23:58:27 -0500
commita34b02006527d28db5df5c6553be804770b81f79 (patch)
tree526fe400e5a8c34b32a3d93439197db09c7f84ad /js/types.js
parentedc3b0640f1b773e185550448e2086279f7b1a7f (diff)
downloadmal-a34b02006527d28db5df5c6553be804770b81f79.tar.gz
mal-a34b02006527d28db5df5c6553be804770b81f79.zip
Fix metadata on functions.
- Don't use metadata to store ast, env, params data. - In Clojure, store metadata on the :meta key of the real metadata. This also allows using any datatype as metadata.
Diffstat (limited to 'js/types.js')
-rw-r--r--js/types.js14
1 files changed, 7 insertions, 7 deletions
diff --git a/js/types.js b/js/types.js
index 6d7de0f..889e154 100644
--- a/js/types.js
+++ b/js/types.js
@@ -100,14 +100,14 @@ function _symbol_Q(obj) { return obj instanceof Symbol; }
// Functions
-function _function(Eval, Env, exp, env, params) {
- var f = function() {
- // TODO: figure out why this throws with 'and' macro
- //throw new Error("Attempt to invoke mal function directly");
- return Eval(exp, new Env(env, params, arguments));
+function _function(Eval, Env, ast, env, params) {
+ var fn = function() {
+ return Eval(ast, new Env(env, params, arguments));
};
- f.__meta__ = {exp: exp, env: env, params: params};
- return f;
+ fn.__meta__ = null;
+ fn.__ast__ = ast;
+ fn.__gen_env__ = function(args) { return new Env(env, params, args); };
+ return fn;
}
function _function_Q(obj) { return typeof obj == "function"; }
Function.prototype.clone = function() {