From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 24 12:10:07 2020 Received: (at 41143) by debbugs.gnu.org; 24 Sep 2020 16:10:07 +0000 Received: from localhost ([127.0.0.1]:41443 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLTot-0000Zc-51 for submit@debbugs.gnu.org; Thu, 24 Sep 2020 12:10:07 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:37543) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLTor-0000Yt-29 for 41143@debbugs.gnu.org; Thu, 24 Sep 2020 12:10:06 -0400 Received: by mail-lf1-f67.google.com with SMTP id z19so4576361lfr.4 for <41143@debbugs.gnu.org>; Thu, 24 Sep 2020 09:10:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=a5iHukRJJLGvVs2UXoDekRWt++wRLcJjO0uQkKnVQ3w=; b=Cdtm+zYl8gS8b14B70w3vkhuPYnoGyJ2HXnVBXJYuE1hirs2160xofzOogo7hKAhSK Or+NwvsXr5mX+ZVQV6qW90A/apup9zhavvtmjK9ZvU2DALs+aSgTaZDAnLxfTT/GMgvX QP+fkSW3UKu1aQIIBxRUr5UdD+kxL91q6s6P+Z+k4NiSIfwOkFOu2kUTtckw+l9tyb9/ GZNPgtdnB3aoAXBFWcKUV70aGm0ToO8Sy0dwo2gfzlc+ORDCEDAVLEErzWMLtcsaonrD 0fj4VcJYMlZQr1Q6CNFnrDvpGZU4X0zxhOSDCFLl/jiWqTd+qP6wCoVj3l0IPEIJ4HSP HBmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=a5iHukRJJLGvVs2UXoDekRWt++wRLcJjO0uQkKnVQ3w=; b=GhD5ZADGv4iZvEAyCK907Yvnyu7Wg/jfUPSKXNhnkHTBp4qvxQZuuGfgRzQfIwuos6 D6YY8xsDxEPQERaovNYl6ce6DN+fueVzR1WR5oDP64aM6MkgbGxIte+wgFt/Rg5DsomI e89Usbp8k4CjE4bgWSYC8aTGRJVreRo9cU0n8PJPmkziYN7Sqh02+CdHDMZCunIUpw2z pkWq+evSCnnYrjQi5StLjZKM6fLFhar212wn+vT+3yYV+kWqJ8TajuSdi/tBNIYFeDre krWdIMytq54dLvfgrMRVAHB3raGxsJnBLZk21en+91Licyc/aQZ2mj7aC4xawUQaXpHu sRsA== X-Gm-Message-State: AOAM533Y75YscScc6mkXpcu9K9V6/5mu5QqSMMuRbBBLt13Mi9DhMCJl MQallqfbCXC6t34mk4MolBwhhQpgoPWH0Q== X-Google-Smtp-Source: ABdhPJxUFADdVgDg/DOy9XoNDH9G1c1QLMMrKlbbnz5e6LAUSfxNBIhYHNHdsNmlOAPU0Xue2ulbxw== X-Received: by 2002:ac2:4c9c:: with SMTP id d28mr62210lfl.93.1600963798681; Thu, 24 Sep 2020 09:09:58 -0700 (PDT) Received: from [192.168.0.143] ([88.201.200.148]) by smtp.gmail.com with ESMTPSA id j8sm2438084lfr.80.2020.09.24.09.09.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Sep 2020 09:09:58 -0700 (PDT) Subject: Re: [bug#41143] [PATCH 1/2] mapped-devices: Allow target to be list of strings To: =?UTF-8?Q?Ludovic_Court=c3=a8s?= References: <874ko6n0s5.fsf@gnu.org> From: Mikhail Tsykalov Message-ID: <9ac560cc-8660-f034-c0d8-536b68d20f68@gmail.com> Date: Thu, 24 Sep 2020 19:09:57 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Icedove/68.12.0 MIME-Version: 1.0 In-Reply-To: <874ko6n0s5.fsf@gnu.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Score: -0.2 (/) X-Debbugs-Envelope-To: 41143 Cc: 41143@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.2 (-) Hi Ludovic, On 09.09.2020 23:38, Ludovic Courtès 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) …) everywhere, I propose instead > the following approach: > > 1. Rename ‘target’ to ‘targets’ (plural) and likewise for the > accessor, and agree that it always contains a list; > > 2. Rename ‘mapped-device’ to ‘%mapped-device’ and add a > ‘mapped-device’ backward-compatibility macro that allows for a > ‘target’ (singular) field and automatically turns its value into a > list. See the ‘origin’ macro in (guix packages) for an example of > how to do that (that macro allows users to specify ‘sha256’ instead > of ‘hash’). > > 3. Add a deprecated ‘mapped-device-target’ (singular) that returns the > first element returned by ‘mapped-device-targets’. While this looks like a good idea, doesn't this break code that implements mapped-device and assumes that target is a string. Suddenly 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. Basically, this change will break all current implementations of mapped-devices, so I wanted to hear your thoughts on it before continuing. Mikhail