Replaced old eval with "expand analyze evaluate-eproc"
[scheme.forth.jl.git] / src / scheme-primitives.4th
index 1ed995b..183efec 100644 (file)
     -rot 2drop boolean-type
 ; 1 make-fa-primitive procedure?
 
+:noname ( args -- boolobj )
+    port-type istype? -rot 2drop boolean-type
+; 1 make-fa-primitive port?
+
 \ }}}
 
 \ ==== Type conversions ==== {{{
     current-input-port obj@
 ; 0 make-fa-primitive current-input-port
 
+:noname ( args -- charobj )
+    nil? if
+        2drop current-input-port obj@
+    else
+        car port-type ensure-arg-type
+    then
+
+    read-char
+; make-primitive read-char
+
+:noname ( args -- charobj )
+    nil? if
+        2drop current-input-port obj@
+    else
+        car port-type ensure-arg-type
+    then
+
+    peek-char
+; make-primitive peek-char
+
+:noname ( args -- stringobj )
+    nil? if
+        2drop current-input-port obj@
+    else
+        car port-type ensure-arg-type
+    then
+
+    read-line
+; make-primitive read-line
+
 : charlist>cstr ( charlist addr -- n )
 
     dup 2swap ( origaddr addr charlist )
@@ -558,13 +592,13 @@ defer display
 
 \ ==== Evaluation ==== {{{
 
-:noname ( args -- result )
-    2dup car 2swap cdr
-
-    nil? false = if car then ( proc argvals )
-    
-    apply
-; make-primitive apply 
+:noname ( args -- result )
+    2dup car 2swap cdr
+\ 
+    nil? false = if car then ( proc argvals )
+\     
+    apply
+; make-primitive apply 
 
 \ }}}
 
@@ -577,7 +611,17 @@ defer display
     nil? if
         ." Error."
     else
-        ." Error: " car display
+        ." Error:"
+
+        2dup car space display
+        cdr nil? invert if
+            begin
+                2dup car space print
+                cdr nil?
+            until
+        then
+
+        2drop
     then
 
     reset-term