summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Price <ianprice90@googlemail.com>2015-06-15 16:34:42 +0100
committerIan Price <ianprice90@googlemail.com>2015-06-18 04:14:43 +0100
commit4622269e684ad5918aff1b7fa29a47ad2c17b0a4 (patch)
tree582008a2a477d3af979a28c06456a9b3ef9fa6c0
parente84f8394633339284953d7e54fe3cd5018d2e160 (diff)
downloadguile-4622269e684ad5918aff1b7fa29a47ad2c17b0a4.tar.gz
Primitives should return Scheme Booleans
-rw-r--r--module/language/js-il/runtime.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/module/language/js-il/runtime.js b/module/language/js-il/runtime.js
index 688974e2e..271e50837 100644
--- a/module/language/js-il/runtime.js
+++ b/module/language/js-il/runtime.js
@@ -19,6 +19,10 @@ function not_implemented_yet() {
throw "not implemented yet";
};
+function coerce_bool(obj) {
+ return obj ? scheme.TRUE : scheme.FALSE;
+};
+
// Numbers
scheme.primitives.add = function (x, y) {
return x + y;
@@ -45,11 +49,12 @@ scheme.primitives.div = function (x, y) {
};
scheme.primitives["="] = function (x, y) {
- return x == y;
+ return coerce_bool(x == y);
};
scheme.primitives["<"] = function (x, y) {
- return x < y;
+ return coerce_bool(x < y);
+};
};
scheme.primitives.quo = not_implemented_yet;
@@ -98,7 +103,7 @@ scheme.list = function () {
};
scheme.primitives["null?"] = function(obj) {
- return scheme.EMPTY == obj;
+ return coerce_bool(scheme.EMPTY == obj);
};
// Symbols