From 0a135e0f384d0f7d7868bed6d12b8251b6e66f98 Mon Sep 17 00:00:00 2001 From: sforman Date: Sat, 21 Oct 2023 19:25:14 -0700 Subject: [PATCH] Runtime type checking for bool. 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 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/implementations/scheme-chicken/joy.scm b/implementations/scheme-chicken/joy.scm index 90c599e..6d4a1d6 100644 --- a/implementations/scheme-chicken/joy.scm +++ b/implementations/scheme-chicken/joy.scm @@ -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)) @@ -135,8 +135,9 @@ ; ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚══╝╚══╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚══════╝ ;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)