From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Janneke Nieuwenhuizen Newsgroups: gmane.lisp.guile.devel Subject: [PATCH] Add peek-error, pke. Date: Wed, 19 Jun 2024 13:44:11 +0200 Message-ID: <20240619114411.7302-1-janneke@gnu.org> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33141"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Wed Jun 19 13:44:48 2024 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sJtk7-0008Pa-Ie for guile-devel@m.gmane-mx.org; Wed, 19 Jun 2024 13:44:47 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJtjh-00053V-DP; Wed, 19 Jun 2024 07:44:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJtje-0004yk-7x for guile-devel@gnu.org; Wed, 19 Jun 2024 07:44:19 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJtjd-0004h9-At; Wed, 19 Jun 2024 07:44:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=4zR64LyxieRt6xn+JY+ts8e5s6iLIcBUYZx+dJDDRlY=; b=il5nV6Mthu2tyN /ZUG59xJMxzTi36Pe1kxZLSTLn4yhU9aFI1QQqyGw3z+JjNUUPImQf7GatXvGnqT7efGwfF+uLauV Z9vogwr0uJ8KLxgqT6MgmmDOi2tN4fKXQ4ARc6aE7hFT+heoLsJSg/KiVSVwPZJO8AUeyKykmdZd+ pZ0ZWdJKkVdzAlf0qFKTKIJ6+2SzsZfOQ2+vUJOVHWwX2AS+j4fkMKsNTYfO5jzmVYH2ugbB3LRZ1 OTF9+moaydUl+Yov3xS1HPSvOWM6A1llD9kXAa3iXwUK9TLAIg84Gzso0EygMEF2l0vxjZa6PjiYT tYA0wU5yWeTvxRx0KZDQ==; X-Mailer: git-send-email 2.45.1 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:22451 Archived-At: 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