unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Value history
@ 2002-08-05  3:12 Greg Hewgill
  2002-08-08 17:46 ` Marius Vollmer
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Hewgill @ 2002-08-05  3:12 UTC (permalink / raw)


I'm a guile newbie and thought it might be interesting to play with some of the
low hanging fruit on the "cool ideas" page. This is my first actual useful
scheme code, so please be gentle. :)

Below is a patch for the "Value history" idea. This diff is against the CVS
head. If anybody has any suggestions for improvement, let me know. I get the
feeling that the eval statement might not be the best way to do the global $<n>
assignment, but it was the only way I could find to make it work.

Greg Hewgill
http://www.hewgill.com

RCS file: /cvs/guile/guile-core/ice-9/boot-9.scm,v
retrieving revision 1.282
diff -c -r1.282 boot-9.scm
*** ice-9/boot-9.scm	7 Jul 2002 05:18:16 -0000	1.282
--- ice-9/boot-9.scm	5 Aug 2002 03:06:11 -0000
***************
*** 2282,2287 ****
--- 2282,2294 ----
  (define before-print-hook (make-hook 1))
  (define after-print-hook (make-hook 1))
  
+ ;;; A counter for numbering the results of interactive expressions
+ ;;; in the repl loop. $$ is always the value of the last printed
+ ;;; result. $<n> where <n> is an integer, is created in the -print
+ ;;; section of the repl loop below.
+ (define repl-counter 0)
+ (define $$ #f)
+ 
  ;;; The default repl-reader function.  We may override this if we've
  ;;; the readline library.
  (define repl-reader
***************
*** 2373,2378 ****
--- 2380,2392 ----
  					(if (or scm-repl-print-unspecified
  						(not (unspecified? result)))
  					    (begin
+ 					      (set! repl-counter (+ repl-counter 1))
+ 					      (set! $$ result)
+ 					      ;; we have to do this with an eval so we can use define
+ 					      (eval
+ 					       `(define ,(string->symbol (string-append "$" (number->string repl-counter))) $$)
+ 					       (interaction-environment))
+ 					      (display (string-append "$" (number->string repl-counter) " => "))
  					      (write result)
  					      (newline))))))
  		     (lambda (result)

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-08-08 23:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-05  3:12 Value history Greg Hewgill
2002-08-08 17:46 ` Marius Vollmer
2002-08-08 21:32   ` Neil Jerram
2002-08-08 23:14     ` Marius Vollmer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).