From: Rodrigo Morales <moralesrodrigo1100@gmail.com>
To: help-guix@gnu.org
Subject: [TIP] Using (@@ module-name binding-name) sometimes might result in "unbound variable"
Date: Tue, 12 Sep 2023 08:24:03 +0000 [thread overview]
Message-ID: <CAGxMbPaUqAv_eHmqUfJp+UYKJCEpcxZR3ovBx-3uYOeuM819oA@mail.gmail.com> (raw)
TL; DR: Today, I wanted to make some experiments with a function,
which is not exported, from a module. I used "@@", but I still got an
error. I spent a significant amount of time trying to solve
this. Someone helped me out. I now want to share this with other Guix
users.
I used @@ as stated in the Guile manual [1], but I kept getting the error
"unbound variable" (please see below).
#+BEGIN_SRC scheme
(@@ (gnu home services fontutils) config->sxml)
#+END_SRC
#+RESULTS:
#+begin_example
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
error: config->sxml: unbound variable
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
#+end_example
Someone at #guile helped me out.
#+BEGIN_SRC scheme
(reload-module (resolve-module '(gnu home services fontutils)))
#+END_SRC
#+BEGIN_EXAMPLE
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling /run/current-system/profile/share/guile/site/3.0/gnu/home/services/fontutils.scm
;;; compiled /home/rdrg/.cache/guile/ccache/3.0-LE-8-4.6/gnu/store/4dc7z9a5is1lv0v2ib9lpc6nvxlqv9gc-guix-1.4.0-10.4dfdd82/share/guile/site/3.0/gnu/home/services/fontutils.scm.go
$5 = #<directory (gnu home services fontutils) 7f763a259e60>
#+END_EXAMPLE
#+BEGIN_SRC scheme
(@@ (gnu home services fontutils) config->sxml)
#+END_SRC
#+RESULTS:
#+BEGIN_EXAMPLE
$6 = #<procedure config->sxml (config)>
#+END_EXAMPLE
Problem fixed.
From what I can see in the messages shown by =reload-module=, this
problem was caused because Guile was using a cached version which
didn't define "config->sxml" (please correct me if I'm wrong).
Would it be possible to mention this possible scenario and the fact
that it can be solved by using =reload-module= in the documentation of
=@@= at the Info manual [1]? I believe there might be other curious
Guix users, like me, who want to call some non-exported functions, and
might encounter the exact same problem.
Perhaps, adding the following
#+BEGIN_QUOTE
Sometimes it might be necessary to revisit the source file by using
(reload-module (resolve-module module-name)) to make sure that
all functions are available.
#+END_QUOTE
as it follows:
#+BEGIN_QUOTE
syntax: @@ module-name binding-name
Refer to the binding named binding-name in module module-name. The
binding must not have been exported by the module. This syntax is
only intended for debugging purposes or as a last
resort. Sometimes it might be necessary to revisit the source file
by using (reload-module (resolve-module module-name)) to make sure
that all functions are available. See Declarative Modules, for
some limitations on the use of @@.
#+END_QUOTE
[1] https://www.gnu.org/software/guile/manual/html_node/Using-Guile-Modules.html#index-_0040_0040
next reply other threads:[~2023-09-12 8:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-12 8:24 Rodrigo Morales [this message]
2023-09-12 8:34 ` [TIP] Using (@@ module-name binding-name) sometimes might result in "unbound variable" Rodrigo Morales
2023-09-13 8:10 ` Simon Tournier
2023-09-14 0:54 ` Rodrigo Morales
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAGxMbPaUqAv_eHmqUfJp+UYKJCEpcxZR3ovBx-3uYOeuM819oA@mail.gmail.com \
--to=moralesrodrigo1100@gmail.com \
--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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.