Nils Gillmann <n...@n0.is> writes:

> Anyways, in which section of the guile Manual would I find "pk"? I've
> done surprisingly little debugging with Guile itself so far.

Unfortunately, pk isn't (yet?) documented.  It apparently stands for
"peek stuff".  It prints and returns the value passed to it.  It's a
useful little shortcut for printing values.  Here are some simple
examples of how to use it:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (pk "hello")

;;; ("hello")
$1 = "hello"
scheme@(guile-user)> (pk (list 1 2 3))

;;; ((1 2 3))
$2 = (1 2 3)
scheme@(guile-user)> (define (1+ n) (+ 1 (pk n)))
scheme@(guile-user)> (1+ 2)

;;; (2)
$3 = 3
scheme@(guile-user)> pk
$4 = #<procedure peek stuff>
--8<---------------cut here---------------end--------------->8---

Note that pk does not print out all values when a procedure returns
multiple values, but it is still quite handy:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (pk (values 1 2))

;;; (1)
$5 = 1
--8<---------------cut here---------------end--------------->8---

I hope that helps!

By the way, if you feel like taking a trip down the rabbit hole, here is
the answer to the somewhat unrelated question of "why did pk only print
the first value?"

https://lists.gnu.org/archive/html/guile-user/2017-06/msg00043.html

-- 
Chris

Attachment: signature.asc
Description: PGP signature

Reply via email to