help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[TIP] Using (@@ module-name binding-name) sometimes might result in "unb


From: Rodrigo Morales
Subject: [TIP] Using (@@ module-name binding-name) sometimes might result in "unbound variable"
Date: Tue, 12 Sep 2023 08:24:03 +0000

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]