From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: Re: nesting with-imported-modules Date: Thu, 20 Feb 2020 10:01:05 +0100 Message-ID: <87imk1ljji.fsf@elephly.net> References: <874kwat0a8.fsf@elephly.net> <8736bpp1pu.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:49475) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4hiB-00052q-Gt for guix-devel@gnu.org; Thu, 20 Feb 2020 04:01:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4hi6-0006f6-D3 for guix-devel@gnu.org; Thu, 20 Feb 2020 04:01:35 -0500 In-reply-to: <8736bpp1pu.fsf@gnu.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane-mx.org@gnu.org Sender: "Guix-devel" To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: guix-devel@gnu.org Ludovic Court=C3=A8s writes: > Hello! > > Ricardo Wurmus 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=E2=80=99= 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 =E2=80=A6 #~(=E2=80=A6)) > > or possibly combining multiple expressions: > > (define e1 (with-imported-modules =E2=80=A6 #~(=E2=80=A6))) > (define e2 (with-imported-modules =E2=80=A6 #~(=E2=80=A6 #$e1 =E2=80=A6= ))) > > in which case modules are appended. > > I couldn=E2=80=99t think of a use case where one would literally write: > > (with-imported-modules =E2=80=A6 > (with-imported-modules =E2=80=A6 > #~(=E2=80=A6))) No, I=E2=80=99m not writing this literally, but I have an expression that u= ses (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 (=E2=80=A6 (gnu build linux-container) =E2=80=A6) #~(begin (use-modules (gnu build linux-container)) =E2=80=A6 #$exp))) (define (generate-exp) (define exp (with-imported-modules (=E2=80=A6 (guix search-paths) =E2=80=A6) #~(begin (use-modules (guix search-paths)) =E2=80=A6))) (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