From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: isc-bind service draft Date: Thu, 16 Nov 2017 17:18:00 +0100 Message-ID: <87fu9eci4n.fsf@gnu.org> References: <87vaijkyam.fsf@gmail.com> <87po8kno54.fsf@gmail.com> <87tvxuewmq.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eFMrk-0005TP-Hr for guix-devel@gnu.org; Thu, 16 Nov 2017 11:18:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eFMrb-0000sX-6g for guix-devel@gnu.org; Thu, 16 Nov 2017 11:18:12 -0500 Received: from hera.aquilenet.fr ([141.255.128.1]:56450) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eFMrb-0000rt-02 for guix-devel@gnu.org; Thu, 16 Nov 2017 11:18:03 -0500 In-Reply-To: <87tvxuewmq.fsf@gmail.com> (Chris Marusich's message of "Wed, 15 Nov 2017 19:21:49 -0800") 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.org@gnu.org Sender: "Guix-devel" To: Chris Marusich Cc: guix-devel@gnu.org Chris Marusich skribis: > Chris Marusich writes: > >>> >>> (define (emit-bind-options-config options) >>> (match options >>> (($ user _ run-directory pid-file >>> listen-v4 listen-v6 listen-port >>> allow-recursion? allow-transfer? >>> allow-update? >>> version hostname server-id) >> >> Some of these slots (e.g., listen-v4) appear to be un-used. Instead of >> listing positional slots by name, maybe it would be better to bind the >> entire to a variable, and then use the >> accessor procedures (e.g., bind-options-configuration-listen-v4) to get >> just the attributes you need. This has the benefit of being more >> resilient to refactorings which change the order of fields in the >> record, also. I realize that a lot of the code in Guix relies on >> positional matching of slots like this, so I don't mind if you keep it >> as-is, but consider my suggestion as food for thought. > > FYI, I just learned that there is a way to do this with pattern matching > in Guile. You can write something like the following: > > (match options > ((? bind-options-configuration? (=3D bind-options-configuration-listen-= v4 listen-v4)) > ;; Do something with listen-v4 > (foo listen-v4))) > > As far as I know, this is the same as writing something like: > > (match options > ((? bind-options-configuration? opts) > (let ((listen-v4 (bind-options-configuration-listen-v4 opts))) > ;; Do something with listen-v4 > (foo listen-v4)))) In this particular case I would argue that the second version is more readable. Ludo=E2=80=99.