* [TIP] Using (@@ module-name binding-name) sometimes might result in "unbound variable"
@ 2023-09-12 8:24 Rodrigo Morales
2023-09-12 8:34 ` Rodrigo Morales
2023-09-13 8:10 ` Simon Tournier
0 siblings, 2 replies; 4+ messages in thread
From: Rodrigo Morales @ 2023-09-12 8:24 UTC (permalink / raw)
To: help-guix
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [TIP] Using (@@ module-name binding-name) sometimes might result in "unbound variable"
2023-09-12 8:24 [TIP] Using (@@ module-name binding-name) sometimes might result in "unbound variable" Rodrigo Morales
@ 2023-09-12 8:34 ` Rodrigo Morales
2023-09-13 8:10 ` Simon Tournier
1 sibling, 0 replies; 4+ messages in thread
From: Rodrigo Morales @ 2023-09-12 8:34 UTC (permalink / raw)
To: help-guix
If this matters: I was helped in #guile. I asked about this in #guix
and two users that tried to help me didn't know what could be the root
cause of the problem.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [TIP] Using (@@ module-name binding-name) sometimes might result in "unbound variable"
2023-09-12 8:24 [TIP] Using (@@ module-name binding-name) sometimes might result in "unbound variable" Rodrigo Morales
2023-09-12 8:34 ` Rodrigo Morales
@ 2023-09-13 8:10 ` Simon Tournier
2023-09-14 0:54 ` Rodrigo Morales
1 sibling, 1 reply; 4+ messages in thread
From: Simon Tournier @ 2023-09-13 8:10 UTC (permalink / raw)
To: Rodrigo Morales, help-guix
Hi,
Thanks for sharing.
On Tue, 12 Sep 2023 at 08:24, Rodrigo Morales <moralesrodrigo1100@gmail.com> wrote:
> I used @@ as stated in the Guile manual [1], but I kept getting the error
> "unbound variable" (please see below).
Indeed.
--8<---------------cut here---------------start------------->8---
$ guix repl
GNU Guile 3.0.9
Copyright (C) 1995-2023 Free Software Foundation, Inc.
Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.
Enter `,help' for help.
scheme@(guix-user)> (define my/config->sxml (@ (gnu home services fontutils) config->sxml))
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.
scheme@(guix-user) [1]> (reload-module (resolve-module '(gnu home services fontutils)))
$1 = #<directory (gnu home services fontutils) 7f9c30eed000>
scheme@(guix-user) [1]> (define my/config->sxml (@ (gnu home services fontutils) config->sxml))
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.
scheme@(guix-user) [2]> (define my/config->sxml (@@ (gnu home services fontutils) config->sxml))
scheme@(guix-user) [2]> my/config->sxml
$2 = #<procedure config->sxml (a)>
scheme@(guix-user) [2]>
--8<---------------cut here---------------end--------------->8---
> #+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
[...]
> [1] https://www.gnu.org/software/guile/manual/html_node/Using-Guile-Modules.html#index-_0040_0040
This proposal is for the Guile manual, right?
Well, I do not know if @@ is something Guix should document.
Cheers,
simon
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [TIP] Using (@@ module-name binding-name) sometimes might result in "unbound variable"
2023-09-13 8:10 ` Simon Tournier
@ 2023-09-14 0:54 ` Rodrigo Morales
0 siblings, 0 replies; 4+ messages in thread
From: Rodrigo Morales @ 2023-09-14 0:54 UTC (permalink / raw)
To: Simon Tournier; +Cc: help-guix
> This proposal is for the Guile manual, right?
You are right. I should have created this thread in the guile mailing
list. I just did it:
https://lists.gnu.org/archive/html/guile-user/2023-09/msg00009.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-09-14 1:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-12 8:24 [TIP] Using (@@ module-name binding-name) sometimes might result in "unbound variable" Rodrigo Morales
2023-09-12 8:34 ` Rodrigo Morales
2023-09-13 8:10 ` Simon Tournier
2023-09-14 0:54 ` Rodrigo Morales
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.