* nesting with-imported-modules
@ 2020-02-01 22:23 Ricardo Wurmus
2020-02-02 15:47 ` Gábor Boskovits
2020-02-05 14:07 ` Ludovic Courtès
0 siblings, 2 replies; 4+ messages in thread
From: Ricardo Wurmus @ 2020-02-01 22:23 UTC (permalink / raw)
To: guix-devel
Hi Guix,
it seems that it is impossible to nest with-imported-modules. A gexp
that is wrapped in multiple layers of with-imported-modules won’t depend
on the list of all mentioned modules but only on the outermost.
This is because with-imported-modules sets the current-imported-modules
parameter without checking if the parameter already has a value.
Should nesting be supported? It seems useful.
--
Ricardo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: nesting with-imported-modules
2020-02-01 22:23 nesting with-imported-modules Ricardo Wurmus
@ 2020-02-02 15:47 ` Gábor Boskovits
2020-02-05 14:07 ` Ludovic Courtès
1 sibling, 0 replies; 4+ messages in thread
From: Gábor Boskovits @ 2020-02-02 15:47 UTC (permalink / raw)
To: Ricardo Wurmus; +Cc: Guix-devel
[-- Attachment #1: Type: text/plain, Size: 846 bytes --]
Hello,
Ricardo Wurmus <rekado@elephly.net> ezt írta (időpont: 2020. febr. 1., Szo
23:23):
> Hi Guix,
>
> it seems that it is impossible to nest with-imported-modules. A gexp
> that is wrapped in multiple layers of with-imported-modules won’t depend
> on the list of all mentioned modules but only on the outermost.
>
> This is because with-imported-modules sets the current-imported-modules
> parameter without checking if the parameter already has a value.
>
> Should nesting be supported? It seems useful.
>
Looks useful to me. Also, it seems to me that with-imported-modules work in
unexpected ways when wrapped inside with-extensions.
What I observed was that adding a with-imported-modules some-guix-module
inside a with-extensions guix broke patch file search. Can that be related?
>
> --
> Ricardo
>
>
[-- Attachment #2: Type: text/html, Size: 1375 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: nesting with-imported-modules
2020-02-01 22:23 nesting with-imported-modules Ricardo Wurmus
2020-02-02 15:47 ` Gábor Boskovits
@ 2020-02-05 14:07 ` Ludovic Courtès
2020-02-20 9:01 ` Ricardo Wurmus
1 sibling, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2020-02-05 14:07 UTC (permalink / raw)
To: Ricardo Wurmus; +Cc: guix-devel
Hello!
Ricardo Wurmus <rekado@elephly.net> skribis:
> it seems that it is impossible to nest with-imported-modules. A gexp
> that is wrapped in multiple layers of with-imported-modules won’t depend
> on the list of all mentioned modules but only on the outermost.
>
> This is because with-imported-modules sets the current-imported-modules
> parameter without checking if the parameter already has a value.
>
> Should nesting be supported? It seems useful.
Is it? :-)
My impression is that one would always write:
(with-imported-modules … #~(…))
or possibly combining multiple expressions:
(define e1 (with-imported-modules … #~(…)))
(define e2 (with-imported-modules … #~(… #$e1 …)))
in which case modules are appended.
I couldn’t think of a use case where one would literally write:
(with-imported-modules …
(with-imported-modules …
#~(…)))
Perhaps I’m missing some pattern where it could be useful though?
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: nesting with-imported-modules
2020-02-05 14:07 ` Ludovic Courtès
@ 2020-02-20 9:01 ` Ricardo Wurmus
0 siblings, 0 replies; 4+ messages in thread
From: Ricardo Wurmus @ 2020-02-20 9:01 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel
Ludovic Courtès <ludo@gnu.org> writes:
> Hello!
>
> Ricardo Wurmus <rekado@elephly.net> skribis:
>
>> it seems that it is impossible to nest with-imported-modules. A gexp
>> that is wrapped in multiple layers of with-imported-modules won’t depend
>> on the list of all mentioned modules but only on the outermost.
>>
>> This is because with-imported-modules sets the current-imported-modules
>> parameter without checking if the parameter already has a value.
>>
>> Should nesting be supported? It seems useful.
>
> Is it? :-)
>
> My impression is that one would always write:
>
> (with-imported-modules … #~(…))
>
> or possibly combining multiple expressions:
>
> (define e1 (with-imported-modules … #~(…)))
> (define e2 (with-imported-modules … #~(… #$e1 …)))
>
> in which case modules are appended.
>
> I couldn’t think of a use case where one would literally write:
>
> (with-imported-modules …
> (with-imported-modules …
> #~(…)))
No, I’m not writing this literally, but I have an expression that uses
(guix search-paths), for example. Then I have another procedure that
takes this expression and wraps it with an expression that uses (gnu
build linux-container).
--8<---------------cut here---------------start------------->8---
(define (containerize exp)
(with-imported-modules (… (gnu build linux-container) …)
#~(begin
(use-modules (gnu build linux-container))
…
#$exp)))
(define (generate-exp)
(define exp
(with-imported-modules (… (guix search-paths) …)
#~(begin
(use-modules (guix search-paths))
…)))
(if container? (containerize exp) exp))
--8<---------------cut here---------------end--------------->8---
The observed effect was that only one of the with-imported-modules calls
had any effect on the final expression.
--
Ricardo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-02-20 9:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-01 22:23 nesting with-imported-modules Ricardo Wurmus
2020-02-02 15:47 ` Gábor Boskovits
2020-02-05 14:07 ` Ludovic Courtès
2020-02-20 9:01 ` Ricardo Wurmus
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
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).