guile-devel
[Top][All Lists]
Advanced

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

Value history


From: Keisuke Nishida
Subject: Value history
Date: Thu, 01 Mar 2001 21:32:03 -0500
User-agent: Wanderlust/2.4.0 (Rio) SEMI/1.13.7 (Awazu) FLIM/1.13.2 (Kasanui) Emacs/21.0.96 (i686-pc-linux-gnu) MULE/5.0 (SAKAKI)

Hello,

This is a quick hack that enables a value history in the current repl.

  guile> 1
  $1 = 1
  guile> (define foo (+ $1 2))
  guile> foo
  $2 = 3
  guile> (define-module (bar))
  $3 = #<directory (bar) 8083090>
  guile> foo
  ERROR: Unbound variable: foo
  ABORT: (unbound-variable)
  guile> $2
  $4 = 3
  guile> 

Index: boot-9.scm
===================================================================
RCS file: /cvs/guile/guile-core/ice-9/boot-9.scm,v
retrieving revision 1.226
diff -u -r1.226 boot-9.scm
--- boot-9.scm  2001/02/21 20:11:44     1.226
+++ boot-9.scm  2001/03/02 02:17:52
@@ -2336,6 +2339,16 @@
     (run-hook before-read-hook)
     (read (current-input-port))))
 
+(define value-history-save
+  (let ((count 0)
+       (history (resolve-module '(value-history))))
+    (lambda (val)
+      (let* ((c (1+ count))
+            (s (string->symbol (simple-format #f "$~A" c))))
+       (simple-format #t "~A = " s)
+       (module-define! history s val)
+       (set! count c)))))
+
 (define (scm-style-repl)
 
   (letrec (
@@ -2402,6 +2415,8 @@
 
           (-eval (lambda (sourc)
                    (repl-report-start-timing)
+                   (module-use! (current-module)
+                                (resolve-module '(value-history)))
                    (start-stack 'repl-stack
                                 (primitive-eval sourc))))
 
@@ -2409,6 +2424,7 @@
                                        (if (or scm-repl-print-unspecified
                                                (not (unspecified? result)))
                                            (begin
+                                             (value-history-save result)
                                              (write result)
                                              (newline))))))
                     (lambda (result)



reply via email to

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