From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id aPO7ENS3dmM7ygAAbAwnHQ (envelope-from ) for ; Thu, 17 Nov 2022 23:38:12 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id mF2pENS3dmNo8QAAauVa8A (envelope-from ) for ; Thu, 17 Nov 2022 23:38:12 +0100 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 BDD21C692 for ; Thu, 17 Nov 2022 23:38:11 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovnW6-0005o6-Ce; Thu, 17 Nov 2022 17:37:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovnW4-0005nj-Qf for guix-devel@gnu.org; Thu, 17 Nov 2022 17:37:52 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovnW4-0004mt-Hq; Thu, 17 Nov 2022 17:37:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=IlTMesEQgbPnLEJPlWbrd/hyrlPJfQBb9a3llCfSL+U=; b=T1kUqwb4it1lCndUJbyJ aFy07R/EuiMr9i+9E4twIcB6T3GYMfKq4xRKie/MYSlnQ1jTqz3YiAVgwx4ZNs/KybvnW4/xMnxlO W4yseFsDv076d0Wi+aIX59XZzqn8EwnIi1gHbavzpr6EpYbgbgLlukzJadn3xgH0j1YXGAxYmoTVB xw2ZeewdsDGNMt1CPZiWFIpZWzJOy2RTf3mzxIAe3xqJi1SXRs+aa1NKh09xyS6sIo884SuT2eMcB S0W2eI4T06CwGEX9ENOhpfsnho98wn/zHRvWKAsMqlqfbi6OfUwdOm5AmMTJPnMyfBV6wp+Age4sW 4XN9JVC+/ybf+A==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovnW3-0000wH-SK; Thu, 17 Nov 2022 17:37:52 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Maxim Cournoyer Cc: 58855@debbugs.gnu.org, guix-devel@gnu.org Subject: Layout of =?utf-8?Q?=E2=80=98define-configuration=E2=80=99?= records References: <20221029034716.11125-1-maxim.cournoyer@gmail.com> <20221029041649.12144-1-maxim.cournoyer@gmail.com> Mail-Followup-To: guix-devel@gnu.org Date: Thu, 17 Nov 2022 23:37:49 +0100 In-Reply-To: <20221029041649.12144-1-maxim.cournoyer@gmail.com> (Maxim Cournoyer's message of "Sat, 29 Oct 2022 00:16:45 -0400") Message-ID: <87zgcpdx6q.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list 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+larch=yhetil.org@gnu.org Sender: guix-devel-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1668724692; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=IlTMesEQgbPnLEJPlWbrd/hyrlPJfQBb9a3llCfSL+U=; b=oqtucKAxMo9wqOj9Y2b0Zb1tViHfmCcBOMnH3ReBXoLRFVtKDYjnvA7z3km71I1pz/9sm+ w5AQeDIxk1JoWvvW+BIO8QCV+26PRTTFmDXJrUXlw9pvnOjL2T3l9v0KQtjIG+vJix6Af4 ognSK8PgTxKR+ZnQ/LTlfQB+MfwVjrWO8FQwSsIe2GvggugWVmNBBuOgyuobP90dgasPod LT0Roshmvuru7dqDNoIH1d0dYkTPzSJRwIPPVGEU0pKCNc9iqoSLejVic/iFyGO7JlybdL xrwZ92uYNjnF0BBfZfqnpFlP8fhCx2UgcViDsUNJSzt8Fdksgp8YfStYi3xOkg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1668724692; a=rsa-sha256; cv=none; b=Boa7TU59qnR/BPf8AhrkXVxdKYotKHiqW7qrkof053K1EXlg22KoCqOpbJWuoZYSTsF/SC qe8rZ9hlz86h01o9xdnDsNvnogTfZkywOtVUHy/4gji1iRVDOkUkUJWlLvKROHG2fjU3C5 3MMDUSLI4ceOtz7tmhgmPAo3iKqZX0D8zW/wRaaiWpxxYRqAMYTl7GnXXBjVl7BPtAE4Nn flsg0VriyAuSTpQFUrGWY4GCYeFnreJ8Un86fsQ+//Ol9p0J8A9OXn+8Ybp+7kLkre/z4X HXjYCszWugxEzxnIQ7WWHV5MWxt/Ct1IBAyGL9ZobTNGhVEwWAZbpbEnM8XMJw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gnu.org header.s=fencepost-gnu-org header.b=T1kUqwb4; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -6.53 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gnu.org header.s=fencepost-gnu-org header.b=T1kUqwb4; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: BDD21C692 X-Spam-Score: -6.53 X-Migadu-Scanner: scn0.migadu.com X-TUID: QdFCeK7LWq+6 Hi, Maxim Cournoyer skribis: > This is so that the first field of the generated record matches the first= one > declared, which makes 'define-configuration' record API compatible with > define-record-type* ones. > > * gnu/services/configuration.scm (define-configuration-helper): Move the > %location field below the ones declared by the user. > * gnu/services/monitoring.scm (zabbix-front-end-config): Adjust match pat= tern > accordingly. [...] > +++ b/gnu/services/configuration.scm > @@ -242,17 +242,17 @@ (define-record-type* #,(id #'stem #'< #'stem #'>) > stem > #,(id #'stem #'make- #'stem) > #,(id #'stem #'stem #'?) > - (%location #,(id #'stem #'stem #'-location) > - (default (and=3D> (current-source-location) > - source-properties->location)) > - (innate)) > #,@(map (lambda (name getter def) > #`(#,name #,getter (default #,def) > (sanitize > #,(id #'stem #'validate- #'stem #'- = name)))) > #'(field ...) > #'(field-getter ...) > - #'(field-default ...))) > + #'(field-default ...)) > + (%location #,(id #'stem #'stem #'-location) > + (default (and=3D> (current-source-location) > + source-properties->location)) > + (innate))) Moving the field last is problematic as we=E2=80=99ve seen for any user that uses =E2=80=98match=E2=80=99 on records=E2=80=94something that=E2=80=99s no= t recommended but still used a lot. > (define (zabbix-front-end-config config) > (match-record config > - (%location db-host db-port db-name db-user db-password db-secret-file > - zabbix-host zabbix-port) > + (db-host db-port db-name db-user db-password db-secret-file > + zabbix-host zabbix-port %location) This change has no effect because =E2=80=98match-record=E2=80=99 matches fi= elds by name, precisely to avoid problems when changing the layout of record types. I=E2=80=99m not sure what was meant by =E2=80=9Ccompatible=E2=80=9D in the = commit log; how fields are laid out is something user code should not be aware of. The only thing to keep in mind is that records must not be matched with =E2=80=98match=E2=80=99 because then the code silently breaks when the reco= rd type layout is changed. This is why =E2=80=98match-record=E2=80=99 was introduc= ed: https://issues.guix.gnu.org/28960#4 One last thing: placing =E2=80=98%location=E2=80=99 first can let us implem= ent: (define (configuration-location config) (struct-ref config 0)) As if there were type inheritance. I didn=E2=80=99t see any indication that this is actually done anywhere, but it could have been the case (it=E2=80= =99s not an unusual pattern) and it=E2=80=99s still something we might want to d= o. Does that make sense? Thanks, Ludo=E2=80=99.