guile-sources
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Value history - latest value


From: Jeff Binder
Subject: Value history - latest value
Date: Mon, 10 Feb 2003 18:13:44 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20021105

This simple patch to the (ice-9 history) module creates a variable called '$$' that always contains the value of the last expression evaluated in repl. This way you can use the latest result without having to check what number it was assigned. Example:

guile> (+ 4 5)
$1 = 9
guile> (+ $$ 6)
$2 = 15
guile> (- $$ 1)
$3 = 14

Jeff Binder

--------------
--- ice-9/history.scm   19 Jul 2001 20:24:49 -0000      1.4
+++ ice-9/history.scm   11 Feb 2003 01:41:54 -0000
@@ -46,6 +46,8 @@

 (process-define-module '((value-history)))

+(define-public $$ #f)
+
 (define (use-value-history x)
   (module-use! (current-module)
               (resolve-module '(value-history))))
@@ -59,6 +61,7 @@
                 (s (string->symbol (simple-format #f "$~A" c))))
            (simple-format #t "~A = " s)
            (module-define! history s v)
+           (set! $$ v)
            (set! count c))))))

 (add-hook! before-eval-hook use-value-history)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]