[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: a GUIX_PACKAGE_PATH / modules puzzle
From: |
Chris Marusich |
Subject: |
Re: a GUIX_PACKAGE_PATH / modules puzzle |
Date: |
Thu, 03 May 2018 00:23:41 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) |
Nils Gillmann <address@hidden> 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
signature.asc
Description: PGP signature
- a GUIX_PACKAGE_PATH / modules puzzle, Nils Gillmann, 2018/05/01
- Re: a GUIX_PACKAGE_PATH / modules puzzle, Chris Marusich, 2018/05/03
- Re: a GUIX_PACKAGE_PATH / modules puzzle, Nils Gillmann, 2018/05/03
- Re: a GUIX_PACKAGE_PATH / modules puzzle,
Chris Marusich <=
- Re: a GUIX_PACKAGE_PATH / modules puzzle, Nils Gillmann, 2018/05/03
- Re: a GUIX_PACKAGE_PATH / modules puzzle, Nils Gillmann, 2018/05/10
- Re: a GUIX_PACKAGE_PATH / modules puzzle, Nils Gillmann, 2018/05/10
- Re: a GUIX_PACKAGE_PATH / modules puzzle, Nils Gillmann, 2018/05/11
- Re: a GUIX_PACKAGE_PATH / modules puzzle, Nils Gillmann, 2018/05/11
- Re: a GUIX_PACKAGE_PATH / modules puzzle, Ricardo Wurmus, 2018/05/12
- Re: a GUIX_PACKAGE_PATH / modules puzzle, Nils Gillmann, 2018/05/12
- Re: a GUIX_PACKAGE_PATH / modules puzzle, Ricardo Wurmus, 2018/05/13
Re: a GUIX_PACKAGE_PATH / modules puzzle, Nils Gillmann, 2018/05/11