Add christine's pk (cpk) and cpk-values!

This commit is contained in:
Vivianne 2024-03-04 13:59:36 -05:00
parent 4ac39aebd1
commit a4938d04e1

View file

@ -3,6 +3,7 @@
#:use-module (ice-9 textual-ports)
#:use-module (ice-9 exceptions)
#:use-module (ice-9 i18n)
#:use-module (ice-9 pretty-print)
#:use-module (web uri)
#:use-module (web client)
#:use-module (web request)
@ -13,6 +14,8 @@
@codepoint-range
@comment
@ws
cpk-values
cpk
cons-hash-list!
hex-string->integer
format-exception-msg
@ -95,4 +98,26 @@
(with-input-from-file path
(λ () (get-string-all (current-input-port)))) #\newline))
;; kludge: emacs mis-renders this as a string, so...
(define hash-semicolon-semicolon
(list->string '(#\# #\; #\;)))
;; for debugging
(define (cpk . vals)
"Peek at values for print debugging, but return 'em"
(display hash-semicolon-semicolon (current-error-port))
(display " cpk\n" (current-error-port))
(pretty-print vals (current-error-port))
;; return the last value
(last vals))
(define-syntax-rule (cpk-values print-these ... body)
;; Like pk, but supporting multiple value return
(call-with-values
(lambda () body)
(lambda vals
(display hash-semicolon-semicolon (current-error-port))
(display " cpk-values\n" (current-error-port))
(pretty-print (list print-these ... '*values:* vals)
(current-error-port))
(apply values vals))))