guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 21/99: Primitives should return Scheme Booleans


From: Christopher Allan Webber
Subject: [Guile-commits] 21/99: Primitives should return Scheme Booleans
Date: Sun, 10 Oct 2021 21:50:46 -0400 (EDT)

cwebber pushed a commit to branch compile-to-js-merge
in repository guile.

commit 4622269e684ad5918aff1b7fa29a47ad2c17b0a4
Author: Ian Price <ianprice90@googlemail.com>
AuthorDate: Mon Jun 15 16:34:42 2015 +0100

    Primitives should return Scheme Booleans
---
 module/language/js-il/runtime.js | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/module/language/js-il/runtime.js b/module/language/js-il/runtime.js
index 688974e..271e508 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]