unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: Tomas Volf <wolf@wolfsden.cz>
To: help-guix@gnu.org
Subject: How to use receive in a phase?
Date: Sun, 29 Oct 2023 02:24:11 +0100	[thread overview]
Message-ID: <ZT20Oyzp97XnJ2bp@ws> (raw)

[-- Attachment #1: Type: text/plain, Size: 3180 bytes --]

Hello,

I am trying to use receive in a phase, but for some reason it fails.  I modified
the hello-world example from the cookbook to demonstrate:

    (use-modules (gnu)
                 (guix build-system gnu)
                 (guix download)
                 (guix licenses)
                 (guix packages))
    
    (package
      (name "hello")
      (version "2.10")
      (source (origin
                (method url-fetch)
                (uri (string-append "mirror://gnu/hello/hello-" version
                                    ".tar.gz"))
                (sha256
                 (base32
                  "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
      (build-system gnu-build-system)
      (arguments
       (list
        #:phases #~(modify-phases %standard-phases
                     (add-after 'unpack 'xxx
                       (λ _
                         (use-modules (ice-9 receive))
                         (receive (a b)
                             (values 1 2)
                           (pk a)
                           (pk b)))))))
      (synopsis "Hello, GNU world: An example GNU package")
      (description
       "GNU Hello prints the message \"Hello, world!\" and then exits.  It
    serves as an example of standard GNU coding practices.  As such, it supports
    command-line arguments, multiple languages, and so on.")
      (home-page "https://www.gnu.org/software/hello/")
      (license gpl3+))

Now when I try to build this package, I get this error:

    starting phase `xxx'
    error: in phase 'xxx': uncaught exception:
    unbound-variable #f "Unbound variable: ~S" (a) #f 
    phase `xxx' failed after 0.0 seconds
    Backtrace:
              11 (primitive-load "/gnu/store/x57gb3dj0cvvpzmy9r2nh32fcnn…")
    In guix/build/gnu-build-system.scm:
        908:2 10 (gnu-build #:source _ #:outputs _ #:inputs _ #:phases . #)
    In ice-9/boot-9.scm:
      1752:10  9 (with-exception-handler _ _ #:unwind? _ # _)
    In srfi/srfi-1.scm:
        634:9  8 (for-each #<procedure 7ffff77d0b80 at guix/build/gnu-b…> …)
    In ice-9/boot-9.scm:
      1752:10  7 (with-exception-handler _ _ #:unwind? _ # _)
    In guix/build/gnu-build-system.scm:
       929:23  6 (_)
    In ice-9/eval.scm:
       173:39  5 (_ #(#(#<directory (guile-user) 7ffff77f7c80>) (# # …)))
       182:19  4 (proc #(#(#<directory (guile-user) 7ffff77f7c80>) (# …)))
       142:16  3 (compile-top-call #<directory (guile-user) 7ffff77f7c80> …)
    In unknown file:
               2 (%resolve-variable (7 . a) #<directory (guile-user) 7ff…>)
    In ice-9/boot-9.scm:
      1685:16  1 (raise-exception _ #:continuable? _)
      1685:16  0 (raise-exception _ #:continuable? _)
    
    ice-9/boot-9.scm:1685:16: In procedure raise-exception:
    Unbound variable: a

Would anyone have any idea what is wrong and how can I correctly call function
returning multiple values in a phase (call-with-values is bit... unwieldy)?

Thank you,
Tomas Volf

-- 
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

                 reply	other threads:[~2023-10-29  1:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZT20Oyzp97XnJ2bp@ws \
    --to=wolf@wolfsden.cz \
    --cc=help-guix@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).