Debugging number->string
[scheme.forth.jl.git] / scheme.4th
index 52ce346..ecbb91b 100644 (file)
@@ -277,41 +277,37 @@ global-env setobj
     global-env fetchobj define-var
 ;
 
-( = Arithmeic = )
+: arg-count-error
+            bold fg red ." Incorrect argument count." reset-term cr
+            abort
+;
 
-: add-prim ( args -- )
-    2dup nil objeq? if
-        2drop
-        0 fixnum-type
+: ensure-arg-count ( args n -- )
+    dup 0= if
+        drop nil objeq? false = if
+            arg-count-error
+        then
     else
-        2dup car drop
-        -rot cdr recurse drop
-        + fixnum-type
+        -rot 2dup nil objeq? if
+            arg-count-error
+        then
+        
+        cdr rot 1- recurse
     then
 ;
-' add-prim make-primitive +
 
-:noname ( args -- )
-    2dup nil objeq? if
-        2drop
-        0 fixnum-type
-    else
-        2dup car drop
-        -rot cdr add-prim drop
-        - fixnum-type
-    then
-; make-primitive -
+: arg-type-error
+            bold fg red ." Incorrect argument type." reset-term cr
+            abort
+;
 
-:noname ( args -- )
-    2dup nil objeq? if
-        2drop
-        1 fixnum-type
-    else
-        2dup car drop
-        -rot cdr recurse drop
-        * fixnum-type
+: ensure-arg-type ( arg type -- arg )
+    istype? false = if
+        arg-type-error
     then
-; make-primitive *
+;
+
+include scheme-primitives.4th
 
 \ }}}