From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id KIw4E9y5bV/SfQAA0tVLHw (envelope-from ) for ; Fri, 25 Sep 2020 09:35:24 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id oIL7Dty5bV+4cQAAB5/wlQ (envelope-from ) for ; Fri, 25 Sep 2020 09:35:24 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id D4D2F940393 for ; Fri, 25 Sep 2020 09:35:23 +0000 (UTC) Received: from localhost ([::1]:35226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLk8Q-0008ME-TI for larch@yhetil.org; Fri, 25 Sep 2020 05:35:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLk86-0008LC-HO for guix-patches@gnu.org; Fri, 25 Sep 2020 05:35:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:59346) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kLk86-00028l-6j for guix-patches@gnu.org; Fri, 25 Sep 2020 05:35:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kLk86-0006px-40 for guix-patches@gnu.org; Fri, 25 Sep 2020 05:35:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41143] [PATCH 1/2] mapped-devices: Allow target to be list of strings Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 25 Sep 2020 09:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41143 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Mikhail Tsykalov Cc: 41143@debbugs.gnu.org Received: via spool by 41143-submit@debbugs.gnu.org id=B41143.160102649826268 (code B ref 41143); Fri, 25 Sep 2020 09:35:02 +0000 Received: (at 41143) by debbugs.gnu.org; 25 Sep 2020 09:34:58 +0000 Received: from localhost ([127.0.0.1]:42659 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLk81-0006pb-Ni for submit@debbugs.gnu.org; Fri, 25 Sep 2020 05:34:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54384) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLk80-0006pP-Pn for 41143@debbugs.gnu.org; Fri, 25 Sep 2020 05:34:57 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:52419) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLk7v-00028B-1r; Fri, 25 Sep 2020 05:34:51 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=60760 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kLk7u-0001kn-IV; Fri, 25 Sep 2020 05:34:50 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <874ko6n0s5.fsf@gnu.org> <9ac560cc-8660-f034-c0d8-536b68d20f68@gmail.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 4 =?UTF-8?Q?Vend=C3=A9miaire?= an 229 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Fri, 25 Sep 2020 11:34:49 +0200 In-Reply-To: <9ac560cc-8660-f034-c0d8-536b68d20f68@gmail.com> (Mikhail Tsykalov's message of "Thu, 24 Sep 2020 19:09:57 +0300") Message-ID: <87r1qq2o92.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -3.3 (---) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: -1.51 X-TUID: 127eY8AquKHj Hi Mikhail, Mikhail Tsykalov skribis: > On 09.09.2020 23:38, Ludovic Court=C3=A8s wrote: >>> diff --git a/gnu/services/base.scm b/gnu/services/base.scm >>> index 0c154d1c4e..3d09e8220c 100644 >>> --- a/gnu/services/base.scm >>> +++ b/gnu/services/base.scm >>> @@ -408,7 +408,10 @@ FILE-SYSTEM." >>> (define (mapped-device->shepherd-service-name md) >>> "Return the symbol that denotes the shepherd service of MD, a >>> ." >>> (symbol-append 'device-mapping- >>> - (string->symbol (mapped-device-target md)))) >>> + (string->symbol (string-join >>> + (let ((t (mapped-device-target md))) >>> + (if (list? t) t (list t))) >>> + "-")))) >> To avoid duplicating the (if (list? t) =E2=80=A6) everywhere, I propose = instead >> the following approach: >> >> 1. Rename =E2=80=98target=E2=80=99 to =E2=80=98targets=E2=80=99 (plur= al) and likewise for the >> accessor, and agree that it always contains a list; >> >> 2. Rename =E2=80=98mapped-device=E2=80=99 to =E2=80=98%mapped-device= =E2=80=99 and add a >> =E2=80=98mapped-device=E2=80=99 backward-compatibility macro that = allows for a >> =E2=80=98target=E2=80=99 (singular) field and automatically turns = its value into a >> list. See the =E2=80=98origin=E2=80=99 macro in (guix packages) f= or an example of >> how to do that (that macro allows users to specify =E2=80=98sha256= =E2=80=99 instead >> of =E2=80=98hash=E2=80=99). >> >> 3. Add a deprecated =E2=80=98mapped-device-target=E2=80=99 (singular)= that returns the >> first element returned by =E2=80=98mapped-device-targets=E2=80=99. > > While this looks like a good idea, doesn't this break code that > implements mapped-device and assumes that target is a string. Suddenly=20 > passing a string to a mapped-device constructor results in a list > passed to open/close. Also, what functions should do if they expect a > string but get a list of them? Ignore everything but the first item? > Implement mandatory check function? Doesn't this change push > complexity out of mapped-device to implementations of it. The intent of what I propose above is (1) to not break existing code, and (2) to avoid duplicating checks and conversions at every call site. #1 is achieved by providing a deprecated =E2=80=98mapped-device-target=E2= =80=99 (singular) procedure, for example. Does that make sense? Thanks, Ludo=E2=80=99.