Factored out application into apply.
authorTim Vaughan <tgvaughan@gmail.com>
Fri, 22 Jul 2016 08:24:23 +0000 (20:24 +1200)
committerTim Vaughan <tgvaughan@gmail.com>
Fri, 22 Jul 2016 08:24:23 +0000 (20:24 +1200)
scheme-primitives.4th
scheme.4th

index 9afc2c2..b347d8a 100644 (file)
@@ -45,7 +45,7 @@
 :noname ( args -- boolobj )
     2dup 1 ensure-arg-count
 
-    car primitive-type istype? -rot 2drop boolean-type
+    car primitive-proc-type istype? -rot 2drop boolean-type
 ; make-primitive procedure?
 
 ( = Type conversions = )
index 1e58af9..c69f0ec 100644 (file)
@@ -911,6 +911,21 @@ defer eval
     then
 ;
 
+: apply ( proc args )
+        2swap dup case
+            primitive-proc-type of
+                drop execute
+            endof
+
+            compound-proc-type of
+                ." Compound procedures not yet implemented."
+            endof
+
+            bold fg red ." Object not applicable. Aboring." reset-term cr
+            abort
+        endcase
+;
+
 :noname ( obj env -- result )
     2swap
 
@@ -957,16 +972,10 @@ defer eval
     application? if
         2over 2over
         operator 2swap eval
-
-        primitive-proc-type istype? false = if
-            bold fg red ." Object not applicable. Aboring." reset-term cr
-            abort
-        then
-
         -2rot
         operands 2swap list-of-vals
 
-        2swap drop execute
+        apply
         exit
     then