From: Greg Hewgill <greg@hewgill.com>
Subject: Value history
Date: Sun, 4 Aug 2002 22:12:15 -0500 [thread overview]
Message-ID: <20020805031214.GA29032@nsx.internal.hewgill.net> (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
next reply other threads:[~2002-08-05 3:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-05 3:12 Greg Hewgill [this message]
2002-08-08 17:46 ` Value history Marius Vollmer
2002-08-08 21:32 ` Neil Jerram
2002-08-08 23:14 ` Marius Vollmer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020805031214.GA29032@nsx.internal.hewgill.net \
--to=greg@hewgill.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).