unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH] Add peek-error, pke.
@ 2024-06-19 11:44 Janneke Nieuwenhuizen
  2024-10-28 10:33 ` [PATCH v2] " janneke
  0 siblings, 1 reply; 2+ messages in thread
From: Janneke Nieuwenhuizen @ 2024-06-19 11:44 UTC (permalink / raw)
  To: guile-devel

Debuging using `pk' is popular in Guile, but not really usable if your
program is as (pseudo-)filter, i.e., writing its output to stdout.

* module/ice-9/boot-9.scm (peek-error, pke): New procedures.
---
 module/ice-9/boot-9.scm | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index 378ae2457..c4ee2b383 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -183,6 +183,16 @@ This is handy for tracing function calls, e.g.:
 
 (define pk peek)
 
+(define (peek-error . stuff)
+  "Like PEEK (PK), writing to (CURRENT-ERROR-PORT)."
+  (newline (current-error-port))
+  (display ";;; " (current-error-port))
+  (write stuff (current-error-port))
+  (newline (current-error-port))
+  (car (last-pair stuff)))
+
+(define pke peek-error)
+
 (define (warn . stuff)
   (newline (current-warning-port))
   (display ";;; WARNING " (current-warning-port))
-- 
2.45.1




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

end of thread, other threads:[~2024-10-28 10:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-19 11:44 [PATCH] Add peek-error, pke Janneke Nieuwenhuizen
2024-10-28 10:33 ` [PATCH v2] " janneke

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).