Load now returns result of last expression.
authorTim Vaughan <tgvaughan@gmail.com>
Tue, 25 Oct 2016 03:57:32 +0000 (16:57 +1300)
committerTim Vaughan <tgvaughan@gmail.com>
Tue, 25 Oct 2016 03:57:32 +0000 (16:57 +1300)
scheme.4th

index b2efe17..7626be8 100644 (file)
@@ -1412,21 +1412,24 @@ include scheme-primitives.4th
     swap -
 ;
 
-: load ( addr n -- )
+: load ( addr n -- finalResult )
     open-input-file
 
     empty-parse-str
 
+    ok-symbol ( port res )
+
     begin
-        2dup read-port
+        2over read-port ( port res obj )
 
         2dup EOF character-type objeq? if
-            2drop close-port
+            2drop 2swap close-port
             exit
         then
 
-        global-env obj@ eval
-        2drop
+        2swap 2drop ( port obj )
+
+        global-env obj@ eval ( port res )
     again
 ;
 
@@ -1458,7 +1461,7 @@ include scheme-primitives.4th
 ;
 
 : test s" fact.scm" ;
-test load
+test load 2drop
 
 forth definitions