OSDN Git Service

Make Python and C interpreters conform.
authorSimon Forman <sforman@hushmail.com>
Mon, 13 Feb 2023 00:17:27 +0000 (16:17 -0800)
committerSimon Forman <sforman@hushmail.com>
Mon, 13 Feb 2023 00:17:27 +0000 (16:17 -0800)
The Python one still checks number before type with get_n_items().
I can live with that for now.

implementations/C/joy.c
implementations/Python/joy.py

index 34d5abc..0064cfe 100644 (file)
@@ -845,7 +845,7 @@ joy(JoyListPtr stack, JoyListPtr expression)
 }
 
 
-/* Set quiet mode by "-q as only command line option. "*/
+/* Set quiet mode by "-q" as only command line option. */
 int quiet = 0;
 
 #define SHH(message) \
@@ -876,7 +876,7 @@ main(int argc, char *argv[])
        line = (char *)GC_malloc(1025);
 
        while (1) {
-               SHH("\njoy? ")
+               SHH("joy? ")
                status = gets_s(line, 1025);
                if (NULL == status) {
                        /*
@@ -893,7 +893,7 @@ main(int argc, char *argv[])
                        TODO: "use feof(3) and ferror(3)"...
 
                        */
-                       SHH("bye\n")
+                       SHH("\n")
                        break;
                }
                s = stack;
index 5f5e71b..080c485 100755 (executable)
@@ -1311,7 +1311,7 @@ def isnt_int(i):
     (Booleans are not integers in Joy.)
     '''
     if not isinstance(i, int) or isinstance(i, bool):
-        raise NotAnIntError(f'Not an integer: {_s(i)}')
+        raise NotAnIntError('Not an integer.')
     return i
 
 
@@ -1320,7 +1320,7 @@ def isnt_bool(b):
     Raise NotABoolError if b isn't a Boolean.
     '''
     if not isinstance(b, bool):
-        raise NotABoolError(f'Not a Boolean value: {_s(b)}')
+        raise NotABoolError('Not a Boolean value.')
     return b
 
 
@@ -1329,7 +1329,7 @@ def isnt_stack(el):
     Raise NotAListError if el isn't a stack/quote/list.
     '''
     if not isinstance(el, tuple):
-        raise NotAListError(f'Not a list: {_s(el)}')
+        raise NotAListError('Not a list.')
     return el
 
 
@@ -2770,4 +2770,4 @@ if __name__ == '__main__':
 ##    jcode = '3 dup [dup mul] times'
 ##    jcode = '0 [1 2 3] [add] step'
 ##    stack, _ = run(jcode, (), dictionary)
-    print(stack_to_string(stack), '•')
+    ##print(stack_to_string(stack))