fringe3 files changed, 9 insertions(+), 1 deletion(-)
NEWS                      | 6 ++++++
doc/ref/scheme-using.texi | 3 ++-
module/ice-9/history.scm  | 1 +

fringemodified   NEWS
fringe@@ -9,6 +9,12 @@ Changes in 3.0.12 (since 3.0.11)
 
 * Notable changes
 
+** The REPL now saves the last result in history as $0
+
+The current behavior is preserved (e.g., results in history are saved in
+$1, $2, etc.) while $0 is always updated to refer to the last value
+returned.
+
 ** Quote characters in read symbols are now deprecated
 
 Warnings will be emitted by the reader when encountering symbols like:
fringemodified   doc/ref/scheme-using.texi
fringe@@ -87,7 +87,8 @@ history} allows you to use the @emph{result} of a previous evaluation in
 a new expression.  When value history is enabled, each evaluation result
 is automatically assigned to the next in the sequence of variables
 @code{$1}, @code{$2}, @dots{}.  You can then use these variables in
-subsequent expressions.
+subsequent expressions.  The last returned value is also made available
+via the @code{$0} variable, for convenience.
 
 @lisp
 scheme@@(guile-user)> (iota 10)
fringemodified   module/ice-9/history.scm
fringe@@ -116,6 +116,7 @@ The list VALUES is used to hift the recent variables $/, $//, and $///.
                 (s (string->symbol (simple-format #f "$~A" c))))
            (simple-format #t "~A = " s)
            (module-define! history s v)
+            (module-define! history "$_" v)
            (module-export! history (list s))
            (set! count c))))))
 

Generated by apteryx using scpaste at Thu Aug 20 13:51:49 2026. JST. (original)