From unknown Sat Jun 21 10:39:43 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#60225 <60225@debbugs.gnu.org> To: bug#60225 <60225@debbugs.gnu.org> Subject: Status: [PATCH] records: match-record supports specifying a different variable name. Reply-To: bug#60225 <60225@debbugs.gnu.org> Date: Sat, 21 Jun 2025 17:39:43 +0000 retitle 60225 [PATCH] records: match-record supports specifying a different= variable name. reassign 60225 guix-patches submitter 60225 Attila Lendvai severity 60225 normal tag 60225 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 20 12:41:22 2022 Received: (at submit) by debbugs.gnu.org; 20 Dec 2022 17:41:22 +0000 Received: from localhost ([127.0.0.1]:46197 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7gcE-0001FO-IM for submit@debbugs.gnu.org; Tue, 20 Dec 2022 12:41:22 -0500 Received: from lists.gnu.org ([209.51.188.17]:48992) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7gcC-0001FI-Os for submit@debbugs.gnu.org; Tue, 20 Dec 2022 12:41:21 -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 1p7gcC-0002X1-EL for guix-patches@gnu.org; Tue, 20 Dec 2022 12:41:20 -0500 Received: from mail-oo1-xc2d.google.com ([2607:f8b0:4864:20::c2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p7gcA-0007gw-7F for guix-patches@gnu.org; Tue, 20 Dec 2022 12:41:20 -0500 Received: by mail-oo1-xc2d.google.com with SMTP id e11-20020a4ab14b000000b0049be568062bso2003535ooo.4 for ; Tue, 20 Dec 2022 09:41:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=X7pN8iTBG4c7zeirHnZZl+77E9qcU3133vXnV7hdG4U=; b=OJlMR2S75QRIevXqD3jUY0xBC7Sfh7OoVMtpmYBrRsOJsTIHy57QS6RtzAL4tdmF5C DhX9O/RYaKHjZUq12/fT7f9c/a6ElwVBh5Eu7ptON9J8h7pvZNLDXdweHFphVfcM5fEr zZ4eg56fGjMj+dVFv9LoWttn9AvQezXuMuwgMdaBtFGPHvvrKg/xJTYW7E3Nw5KU/YFi gInnUzR0XE3iiavLLOHxZAgrzyFcJCE/oL1dksRLhvV/97cgBRqCOeD7gtr17d8jL+C6 7zNWI19g9CaFtmOVUSbhZRTZXYvPxdGHpkrQYJVvW+c/iw7npd2aj3JMYzQ57c3lPl0r gB6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=X7pN8iTBG4c7zeirHnZZl+77E9qcU3133vXnV7hdG4U=; b=uBOh1xwPys2Zy/odA96tT1OPOc+7/Jb17hsAJ6nTewB3Rtlqsp0dduxgn9FtOHoBXY 1L32hsfX8Izmcr1nMcqVFnAXvwXgI/W2ktCmt6UNAP22ymO+S2D+neWPk/jbBWZbQGTR /27hDo/4E+0xP6zfIjXGX8sMvbYhpPk1DxnW4WpoOJm/vtDyLOIhyM7zN1tQ17Xm35// Q1sT/XiVj21mBv0ZcYhs4daZv4B9zPR1ClN5xv7Gq4XQNj6eMlc+3qdsVzguqR6DesnL ZNQA7NvZr4c/1vNOzusNB+o6P+duNAHkSaqRwJ3f9z3LNtA6OLMDnacNpVPvojg4M2Y7 MZsQ== X-Gm-Message-State: AFqh2ko8r55xtRku1eNjNdfyWqvk59KKkMvVy0cSrnq4zKSC2G9VO5wT 3JatXoKcT2z0MLMitlhI/57ITW+qXAs= X-Google-Smtp-Source: AMrXdXv7nZ8nVcnX/bdF7l3bNu7IHoY+icKlqYIUseI8aQWNX4irBSCqSneUkScZ8UQD6M8eiikNSw== X-Received: by 2002:a4a:4fcd:0:b0:4a3:f16e:3d0c with SMTP id c196-20020a4a4fcd000000b004a3f16e3d0cmr5318769oob.0.1671558076514; Tue, 20 Dec 2022 09:41:16 -0800 (PST) Received: from localhost.localdomain ([179.218.10.217]) by smtp.gmail.com with ESMTPSA id g11-20020a4ad84b000000b004a09df5a1dbsm5286329oov.8.2022.12.20.09.41.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 09:41:15 -0800 (PST) From: Attila Lendvai To: guix-patches@gnu.org Subject: [PATCH] records: match-record supports specifying a different variable name. Date: Tue, 20 Dec 2022 14:40:19 -0300 Message-Id: <20221220174018.14433-1-attila@lendvai.name> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::c2d; envelope-from=attila.lendvai@gmail.com; helo=mail-oo1-xc2d.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: submit Cc: Attila Lendvai 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: -2.1 (--) An example: (match-record obj (field1 (field2 custom-var-name) field3) ...) --- guix/records.scm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/guix/records.scm b/guix/records.scm index 13463647c8..0b2487a156 100644 --- a/guix/records.scm +++ b/guix/records.scm @@ -592,13 +592,16 @@ (define-syntax lookup-field (define-syntax match-record-inner (lambda (s) (syntax-case s () - ((_ record type (field rest ...) body ...) - #`(let-syntax ((field-offset (syntax-rules () + ((_ record type ((field-name variable-name) rest ...) body ...) + #'(let-syntax ((field-offset (syntax-rules () ((_ f) - (lookup-field field 0 f))))) + (lookup-field field-name 0 f))))) (let* ((offset (type map-fields field-offset)) - (field (struct-ref record offset))) + (variable-name (struct-ref record offset))) (match-record-inner record type (rest ...) body ...)))) + ((_ record type (field rest ...) body ...) + ;; Redirect to the canonical form above. + #'(match-record-inner record type ((field field) rest ...) body ...)) ((_ record type () body ...) #'(begin body ...))))) -- 2.35.1 From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 21 17:16:08 2022 Received: (at 60225) by debbugs.gnu.org; 21 Dec 2022 22:16:08 +0000 Received: from localhost ([127.0.0.1]:54241 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p87Nf-0005hs-To for submit@debbugs.gnu.org; Wed, 21 Dec 2022 17:16:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35264) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p87Ne-0005hF-7g for 60225@debbugs.gnu.org; Wed, 21 Dec 2022 17:16:06 -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 1p87NY-0004m5-GE; Wed, 21 Dec 2022 17:16:00 -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=hE4ZX8ZTeQYv5RBmNmDehJk8itFeWKapmtme+fw4w2A=; b=HTvubuawOWC8YAMuCGL7 NhdCbgG4ggZXKFrcuclll/7k8URWjlSWqaJRodbSQ1UXIw703kGO1fmsKQYJmNELbSUDurUG/9hXV gn36SVgCj+GjeWfuLZVSJuyQ0HIh1exLI25kqGaBK4rNl6YudGa9zgBnK4bHDy98nvCG6amqKQV5Q jsPDQ+O1J660aSZtuX+nq/kzl1s2JViAwa1KDrURfgLSOrAhKdT9kOOjUHPMxj6xtnK6XdyeXBvhA xX3mdPNz9Z/iDhFCM8TpVRIv6iiXCy2VdzW9txV1+cN3nE1ufDqIq8fDjqXDqCTFaSvGpcpwIqMAX 260UPnTmcGoYOA==; 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 1p87NY-0001w4-4X; Wed, 21 Dec 2022 17:16:00 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Attila Lendvai Subject: Re: bug#60225: [PATCH] records: match-record supports specifying a different variable name. References: <20221220174018.14433-1-attila@lendvai.name> Date: Wed, 21 Dec 2022 23:15:57 +0100 In-Reply-To: <20221220174018.14433-1-attila@lendvai.name> (Attila Lendvai's message of "Tue, 20 Dec 2022 14:40:19 -0300") Message-ID: <871qos4d42.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-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60225 Cc: 60225@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: -3.3 (---) Hi, Attila Lendvai skribis: > An example: > > (match-record obj > (field1 (field2 custom-var-name) field3) > ...) Nice! It looks like a useful extension to me. > - ((_ record type (field rest ...) body ...) > - #`(let-syntax ((field-offset (syntax-rules () > + ((_ record type ((field-name variable-name) rest ...) body ...) > + #'(let-syntax ((field-offset (syntax-rules () I=E2=80=99d just drop =E2=80=98-name=E2=80=99, it=E2=80=99s all names anywa= y. :-) Could you also add a test in =E2=80=98tests/records.scm=E2=80=99 next to th= e others? TIA, Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 21 21:15:51 2022 Received: (at 60225) by debbugs.gnu.org; 22 Dec 2022 02:15:51 +0000 Received: from localhost ([127.0.0.1]:55292 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p8B7e-00087b-Tk for submit@debbugs.gnu.org; Wed, 21 Dec 2022 21:15:51 -0500 Received: from mail-ot1-f42.google.com ([209.85.210.42]:38544) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p8B7d-00087V-Rz for 60225@debbugs.gnu.org; Wed, 21 Dec 2022 21:15:50 -0500 Received: by mail-ot1-f42.google.com with SMTP id p17-20020a9d6951000000b00678306ceb94so331365oto.5 for <60225@debbugs.gnu.org>; Wed, 21 Dec 2022 18:15:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=OqGXTgMuX2+8mYx4/R8M7gaEOjNyyPqL5Q/4WD0Vh08=; b=PW+t/NSVSgNouq4+G69qb/+EGYM9AAls1v8HJTQD5/BoBv95S3QI96mbz/9+NVcdlg ZyIZ5KlO8cfsY2vyBQIcKu3mvwB1HCbs6pNHmR+MGjLOZcgXqv7PYpnr/Yd/mTFCjRYk GmNC0VeBBIYfYuIAccsu+bdVY3nYPPWTMKOJPFIKoR+mcS+J7LUsfoLnDIS6vxr8HYfe KZCDAa3/V9vNSV1bE9rImZ0r+hy5eakhBJnZUZn8y0BfGynXuKYieuJwVrZo+rbm0mIP h5jVr6xVdUZDF5+xAHRS66FFdmbqJ4YkL+VnEzlpz9vPUPCv0/486crnaLkMUzyvP7dC UYCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=OqGXTgMuX2+8mYx4/R8M7gaEOjNyyPqL5Q/4WD0Vh08=; b=opijh7c/ONGo+tSx3mV/6oDNSNGxKhSIwIHo8/DZgCNPC/CcswhrPqU3ASN+MUb0z5 bA60NAoTBYy7U9PFelQVX7SY/Kg66ZtJWGzd6c6JcEST6CsxFKzF5WTcLYWqQEsqytaK H/aB81CiCh5WlSJIpH6xyTmoDaWFUA9xBvwIMYDBurz+W4TLnumqyrQaHGmVWYom+SXX WhPRmqMw4kS5JSpW7OepSFcY1loa5HbHFndNFgGt9MyON2v5iRWHS0G7TTHvgUYsgW8O wItRw917IbWPO2OcVNy/3pzciNzscmiXPm03mPUZNIvT3wYSvyRu91/3A0+XFL3EwO8/ hGdw== X-Gm-Message-State: AFqh2kpcgzt+LuKGWQx/MpXfcJBQsXMNhMiGvw7BDuEsYCcVuwysrQxi jSE8Tk6gkX6ezZon8x6VHHFJFW/epdY= X-Google-Smtp-Source: AMrXdXs4sSnJUlzWUnp3an2wN0G1XG8U0vaGqCQ+Bf+H4OEfilOTCQMpQbUKstqAAhihGDlRlFf+6w== X-Received: by 2002:a9d:480b:0:b0:670:9c6b:e684 with SMTP id c11-20020a9d480b000000b006709c6be684mr1885032otf.22.1671675343787; Wed, 21 Dec 2022 18:15:43 -0800 (PST) Received: from localhost.localdomain ([179.218.10.217]) by smtp.gmail.com with ESMTPSA id k5-20020a544405000000b0035763a9a36csm7361592oiw.44.2022.12.21.18.15.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 18:15:43 -0800 (PST) From: Attila Lendvai To: 60225@debbugs.gnu.org Subject: [PATCH v2 1/2] records: match-record supports specifying a different variable name. Date: Wed, 21 Dec 2022 23:14:55 -0300 Message-Id: <20221222021455.18632-1-attila@lendvai.name> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 60225 Cc: Attila Lendvai 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: -0.8 (/) An example: (match-record obj (field1 (field2 custom-var-name) field3) ...) * guix/records.scm (match-record-inner): Add support for the new syntax. * tests/records.scm ("match-record, simple"): Add a simple test case for the new syntax. --- guix/records.scm | 9 ++++++--- tests/records.scm | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/guix/records.scm b/guix/records.scm index 13463647c8..1f097c7108 100644 --- a/guix/records.scm +++ b/guix/records.scm @@ -592,13 +592,16 @@ (define-syntax lookup-field (define-syntax match-record-inner (lambda (s) (syntax-case s () - ((_ record type (field rest ...) body ...) - #`(let-syntax ((field-offset (syntax-rules () + ((_ record type ((field variable) rest ...) body ...) + #'(let-syntax ((field-offset (syntax-rules () ((_ f) (lookup-field field 0 f))))) (let* ((offset (type map-fields field-offset)) - (field (struct-ref record offset))) + (variable (struct-ref record offset))) (match-record-inner record type (rest ...) body ...)))) + ((_ record type (field rest ...) body ...) + ;; Redirect to the canonical form above. + #'(match-record-inner record type ((field field) rest ...) body ...)) ((_ record type () body ...) #'(begin body ...))))) diff --git a/tests/records.scm b/tests/records.scm index 8504c8d5a5..b1203dfeb7 100644 --- a/tests/records.scm +++ b/tests/records.scm @@ -540,8 +540,8 @@ (define-record-type* foo make-foo (first second) (list first second)) (match-record (foo (first 'a) (second 'b)) - (second first) - (list first second))))) + (second (first first/new-var)) + (list first/new-var second))))) (test-equal "match-record, unknown field" 'syntax-error -- 2.35.1 From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 21 21:17:21 2022 Received: (at 60225) by debbugs.gnu.org; 22 Dec 2022 02:17:21 +0000 Received: from localhost ([127.0.0.1]:55302 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p8B97-000893-Bm for submit@debbugs.gnu.org; Wed, 21 Dec 2022 21:17:21 -0500 Received: from mail-oi1-f171.google.com ([209.85.167.171]:41549) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p8B95-00088v-GI for 60225@debbugs.gnu.org; Wed, 21 Dec 2022 21:17:19 -0500 Received: by mail-oi1-f171.google.com with SMTP id i127so749371oif.8 for <60225@debbugs.gnu.org>; Wed, 21 Dec 2022 18:17:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=ML+g7edwdiyUjQc+UNmpnbSSNI8fh+l0uRMUzrNdaCg=; b=poViqPcuviv4yWkqDQrGWp0yO18tXOVNWgfQIY6OTsfK2pHUi+sPB+XwR7cZ75yb4d TSPdH0y5rWHLNYUOvAKTb+OfbLLfc3adO58TL0ULgafcy6XXGSbpCXKAham9tp2gz5tC 2PMRRHNNELo1OsHU44Rm08mfVGxdhDYeuJWrZjIFKLFIg5YRhKWgF+jrfCGzn5kTpDrh j8K6Q23B9ilFagGJ7LhjgxVubcvGfYMM2YeZk4spa94fTSaYqWCuvbrUR6F5htZAfJgF P3KZUQ6yVDy6SD+h90UQCDRpPFyIsrBJ3ZCnJe0KDuWYwF8I/5vFGw6DMeSh3lt++Snj Rgxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ML+g7edwdiyUjQc+UNmpnbSSNI8fh+l0uRMUzrNdaCg=; b=wpa0K9p8kMN+z/+kIxXJOhHCnpsz68x3bz22BjAsuSOQ6KKV0lZpRfGL7J5+OUSqRz xxY1OHaOIFDIXJrBpM3Ltji20TSdIVbfFpxmnViusIeOOhi6Ka+ZKN9IJiVOTWYvzPR8 wQ4j8v0gH+CUnB0H7KNa1SlUagsYlHvM0gy3KEU2EDZNYctTRzgfoaDQO693f+CqO9mi fkv/+dKR0faJUzsVxQaQPyJHPELY8QI6EadChtdE/M5zfKLWzR1qM2AZfSxzY6DR9ti2 4+qNZflbFy93752KjCLNS+f2/QgepVrJ2XiADSfiBo6XyGDsXohgwF/yULsOZAnS5Jqm w7CQ== X-Gm-Message-State: AFqh2kotrWJLpHubUQ1t+rdlkP6Yd4JnON2mcEC/xQp22MD0vQYk3Zus x1KkmQe3yPfNoDjaIgJI0sHbbE4TN1c= X-Google-Smtp-Source: AMrXdXsooxE+ba2hGxJAiYpT4p/ckezeB6iCLQ7jWn1+9CgD9FVGRF45ytrdyd9id1Rc+ivzP5FXyQ== X-Received: by 2002:a05:6808:21a7:b0:35c:492d:27ad with SMTP id be39-20020a05680821a700b0035c492d27admr2515028oib.30.1671675433995; Wed, 21 Dec 2022 18:17:13 -0800 (PST) Received: from localhost.localdomain ([179.218.10.217]) by smtp.gmail.com with ESMTPSA id k5-20020a544405000000b0035763a9a36csm7361592oiw.44.2022.12.21.18.17.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 18:17:13 -0800 (PST) From: Attila Lendvai To: 60225@debbugs.gnu.org Subject: [PATCH v2 2/2] tests: records: Add a failing test for match-record. Date: Wed, 21 Dec 2022 23:14:57 -0300 Message-Id: <20221222021455.18632-2-attila@lendvai.name> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221222021455.18632-1-attila@lendvai.name> References: <20221222021455.18632-1-attila@lendvai.name> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 60225 Cc: Attila Lendvai 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: -0.7 (/) * tests/records.scm ("match-record, syntactic interference"): New failing test. --- i'm not sure what's going on here, but it looks like a bug to me. i've experienced this in real code, and the error message was not very helpful. tests/records.scm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/records.scm b/tests/records.scm index b1203dfeb7..8a48e2fd07 100644 --- a/tests/records.scm +++ b/tests/records.scm @@ -561,4 +561,27 @@ (define-record-type* foo make-foo (make-fresh-user-module))) (lambda (key . args) key))) +(test-expect-fail 1) +(test-equal "match-record, syntactic interference" + '(1 2) + (begin + (define* (make-form #:optional (bindings '())) + `(begin + (use-modules (guix records)) + + (let ((first 42)) ; here it does not interfere + (define-record-type* foo make-foo + foo? + (first foo-first (default 1)) + (second foo-second)) + + (let (,@bindings) ; but here it does interfere + (match-record (foo (second 2)) + (first second) + (list first second)))))) + ;; This works fine. + (eval (make-form) (make-fresh-user-module)) + ;; But this fails, although I think it shouldn't. + (eval (make-form '((second 43))) (make-fresh-user-module)))) + (test-end) -- 2.35.1 From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 27 17:49:46 2022 Received: (at 60225-done) by debbugs.gnu.org; 27 Dec 2022 22:49:46 +0000 Received: from localhost ([127.0.0.1]:56733 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pAIlW-0001Yv-0W for submit@debbugs.gnu.org; Tue, 27 Dec 2022 17:49:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59664) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pAIlU-0001Yj-HQ for 60225-done@debbugs.gnu.org; Tue, 27 Dec 2022 17:49:44 -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 1pAIlO-0000iV-Om; Tue, 27 Dec 2022 17:49:38 -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=/prWs6WR+6sB+7iC4+RrZNAUQINYYMymZaySBIfKPoI=; b=FoukPd2xMXPS2HVIPRo+ mFaXyfPNir5J7bhhOhPvOAWl+ITIFpKzEPeZxx6am1eY/Kd62xtcxjSqvnGS6Ufdj1GzLDiRye473 5zrlp3JaispP5wPRklwImAP6iWVw5I7jCry9yuP95x6NGH3IjkbI+/pyp3rs19VYd/dNGDLJswT2j glw6FyY6yiEPgx/vMh7kJeMzlvOy4IJ/aRirMSD8HVd3cUOqWAhz3DN5Gk2d0qZdAYPtHbh5aEY2l i8M5wK0H66W/WITZamgmWzPP7F72wSyBE9aaS5cVbBDzuTgSj8bvOKwnrpi/PDKakdGR0kxxAG5DJ wY3jDK5vCMMXRg==; 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 1pAIlO-0001ha-2z; Tue, 27 Dec 2022 17:49:38 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Attila Lendvai Subject: Re: bug#60225: [PATCH] records: match-record supports specifying a different variable name. References: <20221220174018.14433-1-attila@lendvai.name> <20221222021455.18632-1-attila@lendvai.name> Date: Tue, 27 Dec 2022 23:49:36 +0100 In-Reply-To: <20221222021455.18632-1-attila@lendvai.name> (Attila Lendvai's message of "Wed, 21 Dec 2022 23:14:55 -0300") Message-ID: <87wn6ca2db.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-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60225-done Cc: 60225-done@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: -3.3 (---) Hi, Attila Lendvai skribis: > An example: > > (match-record obj > (field1 (field2 custom-var-name) field3) > ...) > > * guix/records.scm (match-record-inner): Add support for the new syntax. > * tests/records.scm ("match-record, simple"): Add a simple test case for = the > new syntax. Applied, thanks! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 27 17:53:20 2022 Received: (at 60225) by debbugs.gnu.org; 27 Dec 2022 22:53:20 +0000 Received: from localhost ([127.0.0.1]:56740 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pAIox-0001ed-KA for submit@debbugs.gnu.org; Tue, 27 Dec 2022 17:53:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60776) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pAIow-0001eR-CK for 60225@debbugs.gnu.org; Tue, 27 Dec 2022 17:53:18 -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 1pAIor-0001OH-5O; Tue, 27 Dec 2022 17:53:13 -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=hn6ABW5op0MTA0U/a3pviXp443EKAAnqMNmXi7Fchk4=; b=M3sXAkLSQLlJ0e8qf1DP 5xmI6ozKZ6EbLMGAGDihOYuhQbBhgrBq8V8IITh1Q2eM6fnVHuRQZvBcn47RrlgK/Q5uwTShyFg4D oEtNaISWJWbELicUUjmsL1xuoffXLOJoryOl0q+KdFt2h598bTbsrGqwB7UvmpFbmCTeu23M9/cMj Hf4AUiB23FTiJh5QOeIyjDmnmE1KLhMijinIoT6aDT/4S8UeNMEcyLcmtEP6Zg7n57A+/YU5+M6RB dKWFH6LKkClSZGaxA+yao8pfwTYhhem35n5ulC+tDwnJA0VRHa+AAZynvJC7YwmyB/SI+Q25+PpkW QHGdjYkdBdj2JA==; 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 1pAIoq-00025W-QH; Tue, 27 Dec 2022 17:53:13 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Attila Lendvai Subject: Re: bug#60225: [PATCH] records: match-record supports specifying a different variable name. References: <20221222021455.18632-1-attila@lendvai.name> <20221222021455.18632-2-attila@lendvai.name> Date: Tue, 27 Dec 2022 23:53:11 +0100 In-Reply-To: <20221222021455.18632-2-attila@lendvai.name> (Attila Lendvai's message of "Wed, 21 Dec 2022 23:14:57 -0300") Message-ID: <87sfh0a27c.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-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60225 Cc: 60225@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: -3.3 (---) Attila Lendvai skribis: > * tests/records.scm ("match-record, syntactic interference"): New failing= test. > --- > > i'm not sure what's going on here, but it looks like a bug to me. [...] > + (let (,@bindings) ; but here it does interfere > + (match-record (foo (second 2)) > + (first second) > + (list first second)))))) This has to do with how macro =E2=80=9Cliterals=E2=80=9D are matched (info = "(guile) Syntax Rules"): A literal matches an input expression if the input expression is an identifier with the same name as the literal, and both are unbound(1). Although literals can be unbound, usually they are bound to allow them to be imported, exported, and renamed. *Note Modules::, for more information on imports and exports. In Guile there are a few standard auxiliary syntax definitions, as specified by R6RS and R7RS: In the example above, the =E2=80=98let=E2=80=99 binding for =E2=80=98second= =E2=80=99 was shadowing the other =E2=80=98second=E2=80=99. (I think this was recently discussed on guix-devel or something.) Ludo=E2=80=99. From unknown Sat Jun 21 10:39:43 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 25 Jan 2023 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator