]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/fuel/eval/eval.factor
FUEL: refactoring to eliminate the eval-result variable
[factor.git] / extra / fuel / eval / eval.factor
index 9d45e63f66941b3813cdb28d658667388f347f20..3e3da114bf8aa0d919ee6b403439775cd31c2755 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2009 Jose Antonio Ortega Ruiz.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays continuations debugger fuel.pprint io
+USING: accessors arrays continuations debugger fry fuel.pprint io
 io.streams.string kernel listener namespaces parser.notes
 prettyprint.config sequences sets vocabs.parser ;
 IN: fuel.eval
@@ -8,9 +8,6 @@ IN: fuel.eval
 SYMBOL: restarts-stack
 V{ } clone restarts-stack set-global
 
-SYMBOL: eval-result
-f eval-result set-global
-
 SYMBOL: eval-res-flag
 t eval-res-flag set-global
 
@@ -31,14 +28,14 @@ t eval-res-flag set-global
     "<~FUEL~>" write nl flush ;
 
 : begin-eval ( -- )
-    f eval-result set-global push-status ;
+    push-status ;
 
-: end-eval ( error/f output -- )
-    eval-result get-global swap send-retort pop-status ;
+: end-eval ( result error/f output -- )
+    swapd send-retort pop-status ;
 
-: eval ( lines -- error/f )
-    [ parse-lines-interactive call( -- ) f ] curry
-    [ dup print-error ] recover ;
+: eval ( lines -- result error/f )
+    '[ _ parse-lines-interactive call( -- x ) f ]
+    [ dup print-error f swap ] recover ;
 
 : eval-usings ( usings -- )
     [ [ use-vocab ] curry ignore-errors ] each ;