OSDN Git Service

Runtime type checking for bool.
authorsforman <sforman@hushmail.com>
Sun, 22 Oct 2023 02:25:14 +0000 (19:25 -0700)
committersforman <sforman@hushmail.com>
Sun, 22 Oct 2023 02:25:14 +0000 (19:25 -0700)
I think I'm going to retire bool in favor of e.g. 0= and null.
Booleans are already Boolean, of course, and symbols should not be
expected to have a valid interpretation in a Boolean context (I think?)

implementations/scheme-chicken/joy.scm

index 90c599e..6d4a1d6 100644 (file)
@@ -70,7 +70,7 @@
     ((= eq)  (values (joy-math-func = stack)  expression dict))
     ((<> != neq) (values (joy-math-func not-equal stack) expression dict))
 
-    ((bool) (joy-bool stack expression dict))
+    ((bool) (values (joy-bool stack) expression dict))
 
     ((dup)    (values (joy-dup stack)    expression dict))
     ((pop)    (values (joy-pop stack)    expression dict))
 ; ╚═════╝ ╚═════╝ ╚═╝  ╚═╝╚══════╝     ╚══╝╚══╝  ╚═════╝ ╚═╝  ╚═╝╚═════╝ ╚══════╝
 ;Core Words
 
-(define (joy-bool stack expression dict)
-  (values (cons (joy-bool-term (car stack)) (cdr stack)) expression dict))
+(define (joy-bool stack0)
+  (receive (term stack) (pop-any stack0)
+    (cons (joy-bool-term term) stack)))
 
 (define (joy-bool-term term)
   (cond ((boolean? term) term)