From unknown Sun Jun 22 00:52:32 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH 0/3] MATCH-RECROD improvements Resent-From: "(" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 27 Apr 2023 22:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63135@debbugs.gnu.org Cc: "\(" , Josselin Poiret X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16826331162582 (code B ref -1); Thu, 27 Apr 2023 22:06:01 +0000 Received: (at submit) by debbugs.gnu.org; 27 Apr 2023 22:05:16 +0000 Received: from localhost ([127.0.0.1]:59965 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ps9jo-0000fa-5L for submit@debbugs.gnu.org; Thu, 27 Apr 2023 18:05:16 -0400 Received: from lists.gnu.org ([209.51.188.17]:43472) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ps9jj-0000fO-GL for submit@debbugs.gnu.org; Thu, 27 Apr 2023 18:05:14 -0400 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 1ps9jj-0004y4-8f for guix-patches@gnu.org; Thu, 27 Apr 2023 18:05:11 -0400 Received: from knopi.disroot.org ([178.21.23.139]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ps9jf-0006wZ-Nx for guix-patches@gnu.org; Thu, 27 Apr 2023 18:05:10 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id EE92440303; Fri, 28 Apr 2023 00:05:03 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zWs4bkZUHxJc; Fri, 28 Apr 2023 00:05:02 +0200 (CEST) From: "(" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1682633102; bh=eHd5bua0xa0E0ekYgEN2ZXU4shzb2CGBu2998xIQ2IE=; h=From:To:Cc:Subject:Date; b=kqy7MIA64H4ewjtlyAJjDSU5Me0gH92bF/SzZtMqYxQwOPsOeQQlfL2KbgzADJWqH p3eE4TmwicvKhepgz3A8vb69lQ1Hq//6rfbGMXrknTpzHv/ldNSJ169LbVmOjDl+dz WEwzSBOgzK26LR4zfzYTIExt/Htm8k4BFvdXMJzkf3A9lskLZabB5o7jqleSU0hwlm 2okn0LwKMIC0ZJpgSWgW6bw9QuTiCDUVPW9ZoPYo+JBOonte4KkTHwfhDCARC6R0rl cvQyK0dh7ctJMwW9bxN8Wjgl75z0UWYOujc1ohQ89cHQjZASaZp/S8Ya6shsdYhwbU j0waBoPq9hQUA== Date: Thu, 27 Apr 2023 23:04:49 +0100 Message-Id: <20230427220452.4972-1-paren@disroot.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=178.21.23.139; envelope-from=paren@disroot.org; helo=knopi.disroot.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) 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.4 (--) Hello Guix, Here are three patches pertaining to MATCH-RECORD; the first mostly by Josselin Poiret, with modifications, and the latter two by me. The former two improve MATCH-RECORD's error reporting, and the last removes a TODO by adding support in MATCH-RECORD for unpacking the values of fields marked THUNKED and DELAYED! -- ( ( (3): records: match-record: Raise a syntax error if TYPE is nonexistent. records: match-record: Display more helpful field-not-found error. records: match-record: Support thunked and delayed fields. guix/records.scm | 95 ++++++++++++++++++++++++++++++----------------- tests/records.scm | 29 +++++++++++++++ 2 files changed, 89 insertions(+), 35 deletions(-) -- 2.39.2 From unknown Sun Jun 22 00:52:32 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH 1/3] records: match-record: Raise a syntax error if TYPE is nonexistent. References: <20230427220452.4972-1-paren@disroot.org> In-Reply-To: <20230427220452.4972-1-paren@disroot.org> Resent-From: "(" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 27 Apr 2023 22:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63135@debbugs.gnu.org Cc: "\(" , Josselin Poiret Received: via spool by 63135-submit@debbugs.gnu.org id=B63135.16826332232791 (code B ref 63135); Thu, 27 Apr 2023 22:08:02 +0000 Received: (at 63135) by debbugs.gnu.org; 27 Apr 2023 22:07:03 +0000 Received: from localhost ([127.0.0.1]:59971 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ps9lW-0000iq-Jc for submit@debbugs.gnu.org; Thu, 27 Apr 2023 18:07:03 -0400 Received: from knopi.disroot.org ([178.21.23.139]:53500) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ps9lV-0000iO-BG for 63135@debbugs.gnu.org; Thu, 27 Apr 2023 18:07:01 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 2B1AC401FC; Fri, 28 Apr 2023 00:07:00 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QMpgJ3mA1ZBP; Fri, 28 Apr 2023 00:06:59 +0200 (CEST) From: "(" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1682633218; bh=GPhznM6wNK5AMuy0Nb33NHq6jGF40qkOAqXeIPrXDZY=; h=From:To:Cc:Subject:Date; b=fSGYPvir7OlnsiG/7szDpE8QUjGFzce5vuywAjVzRo0Z4NZoQDW9ijtimJ4fiSZRz v3AyPKOpaFcJu0k/YVUrhWtqGxMvzhm9HMxMtnFnvVpamsLFHvFf8gJZQKnqvqk470 Au/AhBBpw3d0iS1ekBu1Xd7nP/ZprNxmqtUa3UlUmsCBRgMMnOezBG0qw3NgofyyBm nm0MJ0Q9NFVgC2IL/Mb7USRfvd0VCIPB3nRRJkUzPeI1O51l2mPB4ZgkQIR5SaHYrL daKqsw0qHf6PO8kzHTVuahEXubwJT4kBxiUXyu7NaeyU9G+mQDy7KQhdwJEEBzTRPE tVvlN2L8j7rmg== Date: Thu, 27 Apr 2023 23:06:51 +0100 Message-Id: <20230427220653.5228-1-paren@disroot.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) 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.0 (-) * guix/records.scm (match-record): Raise a human-compherensible syntax error if the given record type identifier is unbound. Co-authored-by: Josselin Poiret --- guix/records.scm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/guix/records.scm b/guix/records.scm index 7d43b064d8..d8966998c1 100644 --- a/guix/records.scm +++ b/guix/records.scm @@ -105,7 +105,12 @@ (define (report-duplicate-field-specifier name ctor) (define-syntax map-fields (lambda (x) - (syntax-violation 'map-fields "bad use of syntactic keyword" x x))) + (syntax-case x () + ((_ type within) + (syntax-violation (syntax->datum #'within) + "undefined guix record-type" + #'type)) + (_ (syntax-violation 'map-fields "bad use of syntactic keyword" x x))))) (define-syntax-parameter this-record (lambda (s) @@ -459,7 +464,7 @@ (define-syntax type "This macro lets us query record type info at macro-expansion time." (syntax-case s (map-fields) - ((_ map-fields macro) + ((_ (map-fields _ _) macro) #'(macro (field ...))) (id (identifier? #'id) @@ -595,7 +600,7 @@ (define-syntax match-record-inner #'(let-syntax ((field-offset (syntax-rules () ((_ f) (lookup-field field 0 f))))) - (let* ((offset (type map-fields field-offset)) + (let* ((offset (type (map-fields type match-record) field-offset)) (variable (struct-ref record offset))) (match-record-inner record type (rest ...) body ...)))) ((_ record type (field rest ...) body ...) base-commit: d59b4764f3171b1430a6d3b954659b8aab730475 -- 2.39.2 From unknown Sun Jun 22 00:52:32 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH 2/3] records: match-record: Display more helpful field-not-found error. Resent-From: "(" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 27 Apr 2023 22:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63135@debbugs.gnu.org Cc: "\(" , Josselin Poiret Received: via spool by 63135-submit@debbugs.gnu.org id=B63135.16826332272807 (code B ref 63135); Thu, 27 Apr 2023 22:08:02 +0000 Received: (at 63135) by debbugs.gnu.org; 27 Apr 2023 22:07:07 +0000 Received: from localhost ([127.0.0.1]:59974 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ps9la-0000jB-GR for submit@debbugs.gnu.org; Thu, 27 Apr 2023 18:07:06 -0400 Received: from knopi.disroot.org ([178.21.23.139]:53992) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ps9lW-0000ib-7p for 63135@debbugs.gnu.org; Thu, 27 Apr 2023 18:07:02 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id BAD2140306; Fri, 28 Apr 2023 00:07:01 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QQQQQgHpRCy5; Fri, 28 Apr 2023 00:07:00 +0200 (CEST) From: "(" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1682633220; bh=aa/TNg6F4FuftaCqmdSb5c/md+/36DE3Ku+qtLN2znA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Lgv8AUJVz1WSThRrGfojcVQksNqw5AryDHhFDoewSIrgqEto5KDn2oZRbUwrWGvrG t81jgkcyMsitt/2LxC1eT2n+FTXUDKb9OqvUkd19HA21jmdEi2FIei12/PdAwC9C30 cRqLs/BfbOGrK6dXuVUbCf8OItdQvCth8+80P1WpTGdBqdAQ4gYAS79/hrW4EOjxKS nSVfNrG/uC95wDZIBSA1QRBKgJ84Wg+XAaRRN1QARaGjn6kyQjyV7n8DUhPjh6A1ss GZhUaKxrxRGnkriAlyMd+H35BXlT5UncxsmsNRAD1WAwdBiROD5Q5/1Czp8Cdnnpft yKuN5JFxEY5Tg== Date: Thu, 27 Apr 2023 23:06:52 +0100 Message-Id: <20230427220653.5228-2-paren@disroot.org> In-Reply-To: <20230427220653.5228-1-paren@disroot.org> References: <20230427220653.5228-1-paren@disroot.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) 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.0 (-) * guix/records.scm (match-record): Display MATCH-RECORD as the origin of "unknown record type field" errors. Show the original MATCH-RECORD form, rather than an intermediate LOOKUP-FIELD form, within said errors. --- guix/records.scm | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/guix/records.scm b/guix/records.scm index d8966998c1..4bee9d0aac 100644 --- a/guix/records.scm +++ b/guix/records.scm @@ -582,44 +582,46 @@ (define-syntax lookup-field (lambda (s) "Look up FIELD in the given list and return an expression that represents its offset in the record. Raise a syntax violation when the field is not -found." +found, displaying it as originating in form S*." (syntax-case s () - ((_ field offset ()) - (syntax-violation 'lookup-field "unknown record type field" - s #'field)) - ((_ field offset (head tail ...)) + ((_ s* field offset ()) + (syntax-violation 'match-record + "unknown record type field" + #'s* #'field)) + ((_ s* field offset (head tail ...)) (free-identifier=? #'field #'head) #'offset) - ((_ field offset (_ tail ...)) - #'(lookup-field field (+ 1 offset) (tail ...)))))) + ((_ s* field offset (_ tail ...)) + #'(lookup-field s* field (+ 1 offset) (tail ...)))))) (define-syntax match-record-inner (lambda (s) (syntax-case s () - ((_ record type ((field variable) rest ...) body ...) + ((_ s* record type ((field variable) rest ...) body ...) #'(let-syntax ((field-offset (syntax-rules () ((_ f) - (lookup-field field 0 f))))) + (lookup-field s* field 0 f))))) (let* ((offset (type (map-fields type match-record) field-offset)) (variable (struct-ref record offset))) - (match-record-inner record type (rest ...) body ...)))) - ((_ record type (field rest ...) body ...) + (match-record-inner s* record type (rest ...) body ...)))) + ((_ s* record type (field rest ...) body ...) ;; Redirect to the canonical form above. - #'(match-record-inner record type ((field field) rest ...) body ...)) - ((_ record type () body ...) + #'(match-record-inner s* record type ((field field) rest ...) body ...)) + ((_ s* record type () body ...) #'(begin body ...))))) (define-syntax match-record - (syntax-rules () + (lambda (s) "Bind each FIELD of a RECORD of the given TYPE to it's FIELD name. The order in which fields appear does not matter. A syntax error is raised if an unknown field is queried. The current implementation does not support thunked and delayed fields." ;; TODO support thunked and delayed fields - ((_ record type (fields ...) body ...) - (if (eq? (struct-vtable record) type) - (match-record-inner record type (fields ...) body ...) - (throw 'wrong-type-arg record))))) + (syntax-case s () + ((_ record type (fields ...) body ...) + #`(if (eq? (struct-vtable record) type) + (match-record-inner #,s record type (fields ...) body ...) + (throw 'wrong-type-arg record)))))) ;;; records.scm ends here -- 2.39.2 From unknown Sun Jun 22 00:52:32 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH 3/3] records: match-record: Support thunked and delayed fields. Resent-From: "(" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 27 Apr 2023 22:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63135@debbugs.gnu.org Cc: "\(" , Josselin Poiret Received: via spool by 63135-submit@debbugs.gnu.org id=B63135.16826332272813 (code B ref 63135); Thu, 27 Apr 2023 22:08:02 +0000 Received: (at 63135) by debbugs.gnu.org; 27 Apr 2023 22:07:07 +0000 Received: from localhost ([127.0.0.1]:59976 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ps9la-0000jE-TJ for submit@debbugs.gnu.org; Thu, 27 Apr 2023 18:07:07 -0400 Received: from knopi.disroot.org ([178.21.23.139]:54110) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ps9lW-0000io-Li for 63135@debbugs.gnu.org; Thu, 27 Apr 2023 18:07:03 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 312BA402CF; Fri, 28 Apr 2023 00:07:02 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SE_5I9hBv7oA; Fri, 28 Apr 2023 00:07:00 +0200 (CEST) From: "(" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1682633220; bh=VR5KpZOjanz7iRoDHHzMvUH88/n7hp56BE3Gxtae7XM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SObSE/22RUtVIwrfNTmgO0VwNlfKsc8T0/w+1PcWwlpLvQbVKO0knl+Ugi83ymk43 QWBjr3JHiIuQ+jz+Luz1fNaXaLG74V7laZ+XOq5g2z1EeuBaGcXWfNz1ggAIk2q4Ey 9i+L/RRsL9SBglpAikckp9ykpmy2T48ta5IYsuecgAm4OjhA931xxMUg3iqKiNBD/y llm7g4+twSEilNNgM9uyX/4ttnT5JCcK6yuUv74T0mXNVdbuSzgjLxCwuAG9ZR8Vds sXbRx2SPVhi6iNkBkWzgUQWEW+YDBwIGYlRC7NPsh+Doshz4i5K1KleFmw7bVdYduu 908fbrmmjkPZw== Date: Thu, 27 Apr 2023 23:06:53 +0100 Message-Id: <20230427220653.5228-3-paren@disroot.org> In-Reply-To: <20230427220653.5228-1-paren@disroot.org> References: <20230427220653.5228-1-paren@disroot.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) 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.0 (-) * guix/records.scm (match-record): Unwrap matched thunked and delayed fields. * tests/records.scm ("match-record, thunked field", "match-record, delayed field"): New tests. --- guix/records.scm | 60 ++++++++++++++++++++++++++++++----------------- tests/records.scm | 29 +++++++++++++++++++++++ 2 files changed, 68 insertions(+), 21 deletions(-) diff --git a/guix/records.scm b/guix/records.scm index 4bee9d0aac..041eb2f297 100644 --- a/guix/records.scm +++ b/guix/records.scm @@ -21,6 +21,7 @@ (define-module (guix records) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) #:use-module (srfi srfi-26) + #:use-module (srfi srfi-71) #:use-module (ice-9 match) #:use-module (ice-9 rdelim) #:autoload (system base target) (target-most-positive-fixnum) @@ -428,10 +429,19 @@ (define (compute-abi-cookie field-specs) (defaults (filter-map field-default-value #'((field properties ...) ...))) (sanitizers (filter-map field-sanitizer - #'((field properties ...) ...))) + #'((field properties ...) ...))) (cookie (compute-abi-cookie field-spec))) (with-syntax (((field-spec* ...) (map field-spec->srfi-9 field-spec)) + ((field-type ...) + (map (match-lambda + ((? thunked-field?) + (datum->syntax s 'thunked)) + ((? delayed-field?) + (datum->syntax s 'delayed)) + (else + (datum->syntax s 'normal))) + field-spec)) ((thunked-field-accessor ...) (filter-map (lambda (field) (and (thunked-field? field) @@ -465,7 +475,7 @@ (define-syntax type macro-expansion time." (syntax-case s (map-fields) ((_ (map-fields _ _) macro) - #'(macro (field ...))) + #'(macro ((field field-type) ...))) (id (identifier? #'id) #'#,(rtd-identifier #'type))))) @@ -578,31 +588,42 @@ (define (recutils->alist port) ;;; Pattern matching. ;;; -(define-syntax lookup-field +(define-syntax lookup-field+wrapper (lambda (s) - "Look up FIELD in the given list and return an expression that represents -its offset in the record. Raise a syntax violation when the field is not -found, displaying it as originating in form S*." - (syntax-case s () - ((_ s* field offset ()) + "Look up FIELD in the given list and return both an expression that represents +its offset in the record and a procedure that wraps it to return its \"true\" value +(for instance, FORCE is returned in the case of a delayed field). RECORD is passed +to thunked values. Raise a syntax violation when the field is not found, displaying +it as originating in form S*." + (syntax-case s (normal delayed thunked) + ((_ s* record field offset ()) (syntax-violation 'match-record "unknown record type field" #'s* #'field)) - ((_ s* field offset (head tail ...)) + ((_ s* record field offset ((head normal) tail ...)) + (free-identifier=? #'field #'head) + #'(values offset identity)) + ((_ s* record field offset ((head delayed) tail ...)) (free-identifier=? #'field #'head) - #'offset) - ((_ s* field offset (_ tail ...)) - #'(lookup-field s* field (+ 1 offset) (tail ...)))))) + #'(values offset force)) + ((_ s* record field offset ((head thunked) tail ...)) + (free-identifier=? #'field #'head) + #'(values offset (cut <> record))) + ((_ s* record field offset (_ tail ...)) + #'(lookup-field+wrapper s* record field + (+ 1 offset) (tail ...)))))) (define-syntax match-record-inner (lambda (s) (syntax-case s () ((_ s* record type ((field variable) rest ...) body ...) - #'(let-syntax ((field-offset (syntax-rules () - ((_ f) - (lookup-field s* field 0 f))))) - (let* ((offset (type (map-fields type match-record) field-offset)) - (variable (struct-ref record offset))) + #'(let-syntax ((field-offset+wrapper + (syntax-rules () + ((_ f) + (lookup-field+wrapper s* record field 0 f))))) + (let* ((offset wrap (type (map-fields type match-record) + field-offset+wrapper)) + (variable (wrap (struct-ref record offset)))) (match-record-inner s* record type (rest ...) body ...)))) ((_ s* record type (field rest ...) body ...) ;; Redirect to the canonical form above. @@ -614,10 +635,7 @@ (define-syntax match-record (lambda (s) "Bind each FIELD of a RECORD of the given TYPE to it's FIELD name. The order in which fields appear does not matter. A syntax error is raised if -an unknown field is queried. - -The current implementation does not support thunked and delayed fields." - ;; TODO support thunked and delayed fields +an unknown field is queried." (syntax-case s () ((_ record type (fields ...) body ...) #`(if (eq? (struct-vtable record) type) diff --git a/tests/records.scm b/tests/records.scm index b1203dfeb7..4f0aeb3903 100644 --- a/tests/records.scm +++ b/tests/records.scm @@ -561,4 +561,33 @@ (define-record-type* foo make-foo (make-fresh-user-module))) (lambda (key . args) key))) +(test-equal "match-record, delayed field" + "foo bar bar foo" + (begin + (define-record-type* with-delayed make-with-delayed + with-delayed? + (delayed with-delayed-delayed + (delayed))) + + (let ((rec (with-delayed + (delayed "foo bar bar foo")))) + (match-record rec (delayed) + delayed)))) + +(test-equal "match-record, thunked field" + '("foo" "foobar") + (begin + (define-record-type* with-thunked make-with-thunked + with-thunked? + (normal with-thunked-normal) + (thunked with-thunked-thunked + (thunked))) + + (let ((rec (with-thunked + (normal "foo") + (thunked (string-append (with-thunked-normal this-record) + "bar"))))) + (match-record rec (normal thunked) + (list normal thunked))))) + (test-end) -- 2.39.2 From unknown Sun Jun 22 00:52:32 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH v2 0/5] MATCH-RECORD improvements References: <20230427220452.4972-1-paren@disroot.org> In-Reply-To: <20230427220452.4972-1-paren@disroot.org> Resent-From: "(" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 28 Apr 2023 19:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63135@debbugs.gnu.org Cc: "\(" , Josselin Poiret Received: via spool by 63135-submit@debbugs.gnu.org id=B63135.168270956023116 (code B ref 63135); Fri, 28 Apr 2023 19:20:01 +0000 Received: (at 63135) by debbugs.gnu.org; 28 Apr 2023 19:19:20 +0000 Received: from localhost ([127.0.0.1]:34532 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1psTcl-00060g-V4 for submit@debbugs.gnu.org; Fri, 28 Apr 2023 15:19:20 -0400 Received: from knopi.disroot.org ([178.21.23.139]:41236) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1psTcj-000605-M9 for 63135@debbugs.gnu.org; Fri, 28 Apr 2023 15:19:18 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 44FC440301; Fri, 28 Apr 2023 21:19:16 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LFCKcweS57ge; Fri, 28 Apr 2023 21:19:15 +0200 (CEST) From: "(" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1682709555; bh=/Sn3sgu9UNd0dyDLhDMWNTGc/G2PQ2ikHB2gunmM5LI=; h=From:To:Cc:Subject:Date; b=aohdYssx+uZwTWllwe/xyQI9Vmk2wG7TMai7w+BqYv4m4aFZJInuq0G2wube2TixM 02PtR4OlBKK+TapboL2YZcx4C2DPZ2EbTWM9u1y6cuViKJOltTjPdSNEQePNxOXARK 86exb2erxtML6BKpqWkUM9MLIW7pYroICUZiwx1bpsL7sKOtCxRZb5rZAitn/wvyn1 6sTXbSRtWSngUbDmB48qc5J82CiwNkuIlbzvro6Pd75x64eHlGAsUBFQmWezmV/u0v ybz2fbCMbN21VgBf7m6gryHM5XyhwDYUVBlpjbHgGzdHHrllZuJUzWd7Dqb4R7aZJF dhM+Chj5q1VyA== Date: Fri, 28 Apr 2023 20:19:00 +0100 Message-Id: <20230428191905.13860-1-paren@disroot.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) 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.0 (-) This v2 fixes the dir-locals.el file so that it indents MATCH-RECORD properly and adds a MATCH-RECORD-LAMBDA macro. ( (5): records: match-record: Raise a syntax error if TYPE is nonexistent. records: match-record: Display more helpful field-not-found error. records: match-record: Support thunked and delayed fields. dir-locals: Fix MATCH-RECORD indentation. records: Add MATCH-RECORD-LAMBDA. .dir-locals.el | 3 +- guix/records.scm | 110 +++++++++++++++++++++++++++++++--------------- tests/records.scm | 41 +++++++++++++++++ 3 files changed, 117 insertions(+), 37 deletions(-) base-commit: d59b4764f3171b1430a6d3b954659b8aab730475 -- 2.39.2 From unknown Sun Jun 22 00:52:32 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH v2 4/5] dir-locals: Fix MATCH-RECORD indentation. Resent-From: "(" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 28 Apr 2023 19:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63135@debbugs.gnu.org Cc: "\(" , Josselin Poiret Received: via spool by 63135-submit@debbugs.gnu.org id=B63135.168270956023123 (code B ref 63135); Fri, 28 Apr 2023 19:20:02 +0000 Received: (at 63135) by debbugs.gnu.org; 28 Apr 2023 19:19:20 +0000 Received: from localhost ([127.0.0.1]:34534 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1psTcm-00060n-6s for submit@debbugs.gnu.org; Fri, 28 Apr 2023 15:19:20 -0400 Received: from knopi.disroot.org ([178.21.23.139]:41590) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1psTck-000608-5B for 63135@debbugs.gnu.org; Fri, 28 Apr 2023 15:19:18 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id A32E840274; Fri, 28 Apr 2023 21:19:17 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Z-0VSZKiypH3; Fri, 28 Apr 2023 21:19:16 +0200 (CEST) From: "(" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1682709556; bh=RQOqLPb86/6MOEVAHzd6IhmBJjOyLl+ukQRIqgZf3aw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kY1H9jUQ8yJLSXlM0ICIB770OzrGrAy9BbzkfZGtlkkN6WSAMv2Az2YTQAZpxvWzi sJiE13uxwD2I/Da5eJfPjuGlKPD73hCin2ZUnkfBHCyYV6p2PyvhqJK0PebIoyLxk0 crPjsHfKrN0wp3/eQHC9pG8evnJIV0yOHuzw+U2RElKyPbni2Ffib8zsMMTYck5Cyg 0BCCHxJFpoFB4uYKiQHjvanKfpgpjEloh7fkYbuAybqGPZuTQ5u9GBaA7O7NyYJ3Md +JNwvX94mwO8ZN4GuQVShgCmVbGoEydRPRTYf2tlO+nYw7aegAEapByTBWgegla7CE 9A1ujTqB0LuqQ== Date: Fri, 28 Apr 2023 20:19:04 +0100 Message-Id: <20230428191905.13860-5-paren@disroot.org> In-Reply-To: <20230428191905.13860-1-paren@disroot.org> References: <20230428191905.13860-1-paren@disroot.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) 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.0 (-) * .dir-locals.el: Treat the fourth form onwards as the body, rather than the third onwards. --- .dir-locals.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dir-locals.el b/.dir-locals.el index a5f627a9ba..3ffd25ee94 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -70,7 +70,7 @@ (eval . (put 'guard 'scheme-indent-function 1)) (eval . (put 'lambda* 'scheme-indent-function 1)) (eval . (put 'substitute* 'scheme-indent-function 1)) - (eval . (put 'match-record 'scheme-indent-function 2)) + (eval . (put 'match-record 'scheme-indent-function 3)) ;; TODO: Contribute these to Emacs' scheme-mode. (eval . (put 'let-keywords 'scheme-indent-function 3)) -- 2.39.2 From unknown Sun Jun 22 00:52:32 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH v2 2/5] records: match-record: Display more helpful field-not-found error. Resent-From: "(" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 28 Apr 2023 19:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63135@debbugs.gnu.org Cc: "\(" , Josselin Poiret Received: via spool by 63135-submit@debbugs.gnu.org id=B63135.168270956023129 (code B ref 63135); Fri, 28 Apr 2023 19:20:02 +0000 Received: (at 63135) by debbugs.gnu.org; 28 Apr 2023 19:19:20 +0000 Received: from localhost ([127.0.0.1]:34536 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1psTcm-00060u-FD for submit@debbugs.gnu.org; Fri, 28 Apr 2023 15:19:20 -0400 Received: from knopi.disroot.org ([178.21.23.139]:41434) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1psTcj-000607-NQ for 63135@debbugs.gnu.org; Fri, 28 Apr 2023 15:19:19 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 155EA40320; Fri, 28 Apr 2023 21:19:17 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7nB_b2AMIdMi; Fri, 28 Apr 2023 21:19:15 +0200 (CEST) From: "(" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1682709555; bh=aa/TNg6F4FuftaCqmdSb5c/md+/36DE3Ku+qtLN2znA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fV9CW7LSXi9ARkPMWRX0vatEhki9vuoVhPNH57YPWP5y7/qSbxi4fZtSgz1qlrGRi ME4U7uMz35JWmjPo8RDzMyr1ywuSMdATBbg3TjmaVs+gVktGS/8iJ+711akgmEvBKS YeLP5rzBjMdHDjVCdXqjhikwxyPrLc1fyXOVndBFH0T7kk4r75wHsfWq26qmOFzGMy gYX+0/QHMZgGdBARfaGn6Mg4qQOKh9LQSwyKRIyVApYgsOKVX4XRWaFJEsHaPwZsH8 neJg9p1J2PxPc5MGX1VPCB7JRBT32sAbbtPDr0D7gBXf0QqoJiceD6euNMaMuU5Y3Q PnlS+T56eQLsA== Date: Fri, 28 Apr 2023 20:19:02 +0100 Message-Id: <20230428191905.13860-3-paren@disroot.org> In-Reply-To: <20230428191905.13860-1-paren@disroot.org> References: <20230428191905.13860-1-paren@disroot.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) 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.0 (-) * guix/records.scm (match-record): Display MATCH-RECORD as the origin of "unknown record type field" errors. Show the original MATCH-RECORD form, rather than an intermediate LOOKUP-FIELD form, within said errors. --- guix/records.scm | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/guix/records.scm b/guix/records.scm index d8966998c1..4bee9d0aac 100644 --- a/guix/records.scm +++ b/guix/records.scm @@ -582,44 +582,46 @@ (define-syntax lookup-field (lambda (s) "Look up FIELD in the given list and return an expression that represents its offset in the record. Raise a syntax violation when the field is not -found." +found, displaying it as originating in form S*." (syntax-case s () - ((_ field offset ()) - (syntax-violation 'lookup-field "unknown record type field" - s #'field)) - ((_ field offset (head tail ...)) + ((_ s* field offset ()) + (syntax-violation 'match-record + "unknown record type field" + #'s* #'field)) + ((_ s* field offset (head tail ...)) (free-identifier=? #'field #'head) #'offset) - ((_ field offset (_ tail ...)) - #'(lookup-field field (+ 1 offset) (tail ...)))))) + ((_ s* field offset (_ tail ...)) + #'(lookup-field s* field (+ 1 offset) (tail ...)))))) (define-syntax match-record-inner (lambda (s) (syntax-case s () - ((_ record type ((field variable) rest ...) body ...) + ((_ s* record type ((field variable) rest ...) body ...) #'(let-syntax ((field-offset (syntax-rules () ((_ f) - (lookup-field field 0 f))))) + (lookup-field s* field 0 f))))) (let* ((offset (type (map-fields type match-record) field-offset)) (variable (struct-ref record offset))) - (match-record-inner record type (rest ...) body ...)))) - ((_ record type (field rest ...) body ...) + (match-record-inner s* record type (rest ...) body ...)))) + ((_ s* record type (field rest ...) body ...) ;; Redirect to the canonical form above. - #'(match-record-inner record type ((field field) rest ...) body ...)) - ((_ record type () body ...) + #'(match-record-inner s* record type ((field field) rest ...) body ...)) + ((_ s* record type () body ...) #'(begin body ...))))) (define-syntax match-record - (syntax-rules () + (lambda (s) "Bind each FIELD of a RECORD of the given TYPE to it's FIELD name. The order in which fields appear does not matter. A syntax error is raised if an unknown field is queried. The current implementation does not support thunked and delayed fields." ;; TODO support thunked and delayed fields - ((_ record type (fields ...) body ...) - (if (eq? (struct-vtable record) type) - (match-record-inner record type (fields ...) body ...) - (throw 'wrong-type-arg record))))) + (syntax-case s () + ((_ record type (fields ...) body ...) + #`(if (eq? (struct-vtable record) type) + (match-record-inner #,s record type (fields ...) body ...) + (throw 'wrong-type-arg record)))))) ;;; records.scm ends here -- 2.39.2 From unknown Sun Jun 22 00:52:32 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH v2 5/5] records: Add MATCH-RECORD-LAMBDA. Resent-From: "(" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 28 Apr 2023 19:20:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63135@debbugs.gnu.org Cc: "\(" , Josselin Poiret Received: via spool by 63135-submit@debbugs.gnu.org id=B63135.168270956123138 (code B ref 63135); Fri, 28 Apr 2023 19:20:03 +0000 Received: (at 63135) by debbugs.gnu.org; 28 Apr 2023 19:19:21 +0000 Received: from localhost ([127.0.0.1]:34538 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1psTcm-000615-UH for submit@debbugs.gnu.org; Fri, 28 Apr 2023 15:19:21 -0400 Received: from knopi.disroot.org ([178.21.23.139]:41768) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1psTck-00060H-Us for 63135@debbugs.gnu.org; Fri, 28 Apr 2023 15:19:19 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 358B44021E; Fri, 28 Apr 2023 21:19:18 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PBCvUDFffq0U; Fri, 28 Apr 2023 21:19:17 +0200 (CEST) From: "(" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1682709556; bh=73P5wsZTJ6hDn+xXhAEBY6bfYosiRAiY3VVjTHHz1Kc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QEmJ9uKAGI2WWRhC/AzyLSwDXXpqjvEavfsvFFmtHoxmGC1PImlcalhxVI+rHY7K5 QqLGZ9g5XvN4rEEhhe+AKChydkBNT/+91maEKHCKuydP1jer7FJAyPJAcqPgcyXz+K m7ismylrMj5nei/N+0dAnOkI4IQsxKxpCR+4sCJL8ZsvjKH+cjWkyEIUNx792Knd4o pexECYPS257XJB1MVw2Ap+Gy8sRbtHZcS1bEKsM53bvOunjeWrbXhFrkujNTHpbJvf xYmktTxyDsY3Xf8ksJsXwCJLctJVDyiBlIxrYFtwmhVTNGCQjjV48nSqfa48VYMACB x6miogJY9AHgw== Date: Fri, 28 Apr 2023 20:19:05 +0100 Message-Id: <20230428191905.13860-6-paren@disroot.org> In-Reply-To: <20230428191905.13860-1-paren@disroot.org> References: <20230428191905.13860-1-paren@disroot.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) 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.0 (-) * guix/records.scm (match-record-lambda): New syntax. * tests/records.scm ("match-record-lambda"): New test. --- .dir-locals.el | 1 + guix/records.scm | 15 ++++++++++++++- tests/records.scm | 12 ++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/.dir-locals.el b/.dir-locals.el index 3ffd25ee94..d79b5c9d7e 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -71,6 +71,7 @@ (eval . (put 'lambda* 'scheme-indent-function 1)) (eval . (put 'substitute* 'scheme-indent-function 1)) (eval . (put 'match-record 'scheme-indent-function 3)) + (eval . (put 'match-record-lambda 'scheme-indent-function 2)) ;; TODO: Contribute these to Emacs' scheme-mode. (eval . (put 'let-keywords 'scheme-indent-function 3)) diff --git a/guix/records.scm b/guix/records.scm index 041eb2f297..504a023e87 100644 --- a/guix/records.scm +++ b/guix/records.scm @@ -31,7 +31,8 @@ (define-module (guix records) alist->record object->fields recutils->alist - match-record)) + match-record + match-record-lambda)) ;;; Commentary: ;;; @@ -642,4 +643,16 @@ (define-syntax match-record (match-record-inner #,s record type (fields ...) body ...) (throw 'wrong-type-arg record)))))) +(define-syntax match-record-lambda + (lambda (s) + "Return a procedure accepting a single record of the given TYPE for which each +FIELD will be bound to its FIELD name within the returned procedure. A syntax error +is raised if an unknown field is queried." + (syntax-case s () + ((_ type (field ...) body ...) + #`(lambda (record) + (if (eq? (struct-vtable record) type) + (match-record-inner #,s record type (field ...) body ...) + (throw 'wrong-type-arg record))))))) + ;;; records.scm ends here diff --git a/tests/records.scm b/tests/records.scm index 4f0aeb3903..8ee306bddc 100644 --- a/tests/records.scm +++ b/tests/records.scm @@ -590,4 +590,16 @@ (define-record-type* with-thunked make-with-thunked (match-record rec (normal thunked) (list normal thunked))))) +(test-equal "match-record-lambda" + '("thing: foo" "thing: bar") + (begin + (define-record-type* with-text make-with-text + with-text? + (text with-text-text)) + + (map (match-record-lambda (text) + (string-append "thing: " text)) + (list (with-text (text "foo")) + (with-text (text "bar")))))) + (test-end) -- 2.39.2 From unknown Sun Jun 22 00:52:32 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH v2 3/5] records: match-record: Support thunked and delayed fields. Resent-From: "(" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 28 Apr 2023 19:20:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63135@debbugs.gnu.org Cc: "\(" , Josselin Poiret Received: via spool by 63135-submit@debbugs.gnu.org id=B63135.168270956223145 (code B ref 63135); Fri, 28 Apr 2023 19:20:03 +0000 Received: (at 63135) by debbugs.gnu.org; 28 Apr 2023 19:19:22 +0000 Received: from localhost ([127.0.0.1]:34540 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1psTcn-000619-AO for submit@debbugs.gnu.org; Fri, 28 Apr 2023 15:19:21 -0400 Received: from knopi.disroot.org ([178.21.23.139]:41632) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1psTck-00060A-B2 for 63135@debbugs.gnu.org; Fri, 28 Apr 2023 15:19:19 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id B663240316; Fri, 28 Apr 2023 21:19:17 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1Dl51W6z95T8; Fri, 28 Apr 2023 21:19:16 +0200 (CEST) From: "(" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1682709556; bh=VR5KpZOjanz7iRoDHHzMvUH88/n7hp56BE3Gxtae7XM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kPcU7yCT+hatnu3N85nZNDXeAD6i5uLg0pBy398tvQ/6iER3r2X6IyGeBMiixqu7o Sz0H2PURAMtzhiH6ezZ0CD4NfTmsiUsw7UCT8zr+xD3rzAXl3h7kiuBup2wA9TELGD In+p0fCD68ofN6bHshT/VFIv/3A9gNBr4E50POVaOC8fCDOTnvQlY6bk/ahwBhLLHL jk+rTbPiWjiLGpeXgq5XECZxM5DKZStL+zXKZJDie+n6zbPHidIpYsM8A3vuXOl7ec lhM031MWW8XKwxx37NbyWbFOFKE20lsWiTtyFLlVM3HQgc3xnWP7bpWuU+UAPO18gt 4ZX/3ObuldBtA== Date: Fri, 28 Apr 2023 20:19:03 +0100 Message-Id: <20230428191905.13860-4-paren@disroot.org> In-Reply-To: <20230428191905.13860-1-paren@disroot.org> References: <20230428191905.13860-1-paren@disroot.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) 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.0 (-) * guix/records.scm (match-record): Unwrap matched thunked and delayed fields. * tests/records.scm ("match-record, thunked field", "match-record, delayed field"): New tests. --- guix/records.scm | 60 ++++++++++++++++++++++++++++++----------------- tests/records.scm | 29 +++++++++++++++++++++++ 2 files changed, 68 insertions(+), 21 deletions(-) diff --git a/guix/records.scm b/guix/records.scm index 4bee9d0aac..041eb2f297 100644 --- a/guix/records.scm +++ b/guix/records.scm @@ -21,6 +21,7 @@ (define-module (guix records) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) #:use-module (srfi srfi-26) + #:use-module (srfi srfi-71) #:use-module (ice-9 match) #:use-module (ice-9 rdelim) #:autoload (system base target) (target-most-positive-fixnum) @@ -428,10 +429,19 @@ (define (compute-abi-cookie field-specs) (defaults (filter-map field-default-value #'((field properties ...) ...))) (sanitizers (filter-map field-sanitizer - #'((field properties ...) ...))) + #'((field properties ...) ...))) (cookie (compute-abi-cookie field-spec))) (with-syntax (((field-spec* ...) (map field-spec->srfi-9 field-spec)) + ((field-type ...) + (map (match-lambda + ((? thunked-field?) + (datum->syntax s 'thunked)) + ((? delayed-field?) + (datum->syntax s 'delayed)) + (else + (datum->syntax s 'normal))) + field-spec)) ((thunked-field-accessor ...) (filter-map (lambda (field) (and (thunked-field? field) @@ -465,7 +475,7 @@ (define-syntax type macro-expansion time." (syntax-case s (map-fields) ((_ (map-fields _ _) macro) - #'(macro (field ...))) + #'(macro ((field field-type) ...))) (id (identifier? #'id) #'#,(rtd-identifier #'type))))) @@ -578,31 +588,42 @@ (define (recutils->alist port) ;;; Pattern matching. ;;; -(define-syntax lookup-field +(define-syntax lookup-field+wrapper (lambda (s) - "Look up FIELD in the given list and return an expression that represents -its offset in the record. Raise a syntax violation when the field is not -found, displaying it as originating in form S*." - (syntax-case s () - ((_ s* field offset ()) + "Look up FIELD in the given list and return both an expression that represents +its offset in the record and a procedure that wraps it to return its \"true\" value +(for instance, FORCE is returned in the case of a delayed field). RECORD is passed +to thunked values. Raise a syntax violation when the field is not found, displaying +it as originating in form S*." + (syntax-case s (normal delayed thunked) + ((_ s* record field offset ()) (syntax-violation 'match-record "unknown record type field" #'s* #'field)) - ((_ s* field offset (head tail ...)) + ((_ s* record field offset ((head normal) tail ...)) + (free-identifier=? #'field #'head) + #'(values offset identity)) + ((_ s* record field offset ((head delayed) tail ...)) (free-identifier=? #'field #'head) - #'offset) - ((_ s* field offset (_ tail ...)) - #'(lookup-field s* field (+ 1 offset) (tail ...)))))) + #'(values offset force)) + ((_ s* record field offset ((head thunked) tail ...)) + (free-identifier=? #'field #'head) + #'(values offset (cut <> record))) + ((_ s* record field offset (_ tail ...)) + #'(lookup-field+wrapper s* record field + (+ 1 offset) (tail ...)))))) (define-syntax match-record-inner (lambda (s) (syntax-case s () ((_ s* record type ((field variable) rest ...) body ...) - #'(let-syntax ((field-offset (syntax-rules () - ((_ f) - (lookup-field s* field 0 f))))) - (let* ((offset (type (map-fields type match-record) field-offset)) - (variable (struct-ref record offset))) + #'(let-syntax ((field-offset+wrapper + (syntax-rules () + ((_ f) + (lookup-field+wrapper s* record field 0 f))))) + (let* ((offset wrap (type (map-fields type match-record) + field-offset+wrapper)) + (variable (wrap (struct-ref record offset)))) (match-record-inner s* record type (rest ...) body ...)))) ((_ s* record type (field rest ...) body ...) ;; Redirect to the canonical form above. @@ -614,10 +635,7 @@ (define-syntax match-record (lambda (s) "Bind each FIELD of a RECORD of the given TYPE to it's FIELD name. The order in which fields appear does not matter. A syntax error is raised if -an unknown field is queried. - -The current implementation does not support thunked and delayed fields." - ;; TODO support thunked and delayed fields +an unknown field is queried." (syntax-case s () ((_ record type (fields ...) body ...) #`(if (eq? (struct-vtable record) type) diff --git a/tests/records.scm b/tests/records.scm index b1203dfeb7..4f0aeb3903 100644 --- a/tests/records.scm +++ b/tests/records.scm @@ -561,4 +561,33 @@ (define-record-type* foo make-foo (make-fresh-user-module))) (lambda (key . args) key))) +(test-equal "match-record, delayed field" + "foo bar bar foo" + (begin + (define-record-type* with-delayed make-with-delayed + with-delayed? + (delayed with-delayed-delayed + (delayed))) + + (let ((rec (with-delayed + (delayed "foo bar bar foo")))) + (match-record rec (delayed) + delayed)))) + +(test-equal "match-record, thunked field" + '("foo" "foobar") + (begin + (define-record-type* with-thunked make-with-thunked + with-thunked? + (normal with-thunked-normal) + (thunked with-thunked-thunked + (thunked))) + + (let ((rec (with-thunked + (normal "foo") + (thunked (string-append (with-thunked-normal this-record) + "bar"))))) + (match-record rec (normal thunked) + (list normal thunked))))) + (test-end) -- 2.39.2 From unknown Sun Jun 22 00:52:32 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH v2 1/5] records: match-record: Raise a syntax error if TYPE is nonexistent. Resent-From: "(" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 28 Apr 2023 19:20:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63135@debbugs.gnu.org Cc: "\(" , Josselin Poiret Received: via spool by 63135-submit@debbugs.gnu.org id=B63135.168270956223151 (code B ref 63135); Fri, 28 Apr 2023 19:20:04 +0000 Received: (at 63135) by debbugs.gnu.org; 28 Apr 2023 19:19:22 +0000 Received: from localhost ([127.0.0.1]:34542 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1psTcn-00061G-Qr for submit@debbugs.gnu.org; Fri, 28 Apr 2023 15:19:22 -0400 Received: from knopi.disroot.org ([178.21.23.139]:41914) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1psTcl-00060U-Gy for 63135@debbugs.gnu.org; Fri, 28 Apr 2023 15:19:19 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 0323B40274; Fri, 28 Apr 2023 21:19:19 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QQTJKUjPd4rO; Fri, 28 Apr 2023 21:19:15 +0200 (CEST) From: "(" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1682709555; bh=8BmRwHNyibV4LMLlHFnVJrXMVrH1J/ivFDj7yyHIQKM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BuBC4y/xa8T62CYq7v2HhLy/Ep/NT0Xfu0vYmzjKPAccADO36SquZPU/eXv44rbG7 NWdLiaWn1FrPF/0fu1FKm2vJwvwKsQs8oIpW9hholNS9rEjBTxWyJDzC9Y7ycOm63Y G29jMVYhRqzdaWX+U+kTvq5JAYwStYrqopjt0+VbqX+C4FrcvAfjdUgV2vKl1WiZVj J64tp23IXvkLL1V+0W312yUZ86cf0FoB2y0VNMz7xno10L625LkgZ4PD/uUx+Mjluf 8aMmsXpdlswMbvgJiHJdUJofI/Du/71YSmeAVtNT18cptcxY8YUaKoCa9Gz1jYZY2n UzcjD0JxvIzpw== Date: Fri, 28 Apr 2023 20:19:01 +0100 Message-Id: <20230428191905.13860-2-paren@disroot.org> In-Reply-To: <20230428191905.13860-1-paren@disroot.org> References: <20230428191905.13860-1-paren@disroot.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) 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.0 (-) * guix/records.scm (match-record): Raise a human-compherensible syntax error if the given record type identifier is unbound. Co-authored-by: Josselin Poiret --- guix/records.scm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/guix/records.scm b/guix/records.scm index 7d43b064d8..d8966998c1 100644 --- a/guix/records.scm +++ b/guix/records.scm @@ -105,7 +105,12 @@ (define (report-duplicate-field-specifier name ctor) (define-syntax map-fields (lambda (x) - (syntax-violation 'map-fields "bad use of syntactic keyword" x x))) + (syntax-case x () + ((_ type within) + (syntax-violation (syntax->datum #'within) + "undefined guix record-type" + #'type)) + (_ (syntax-violation 'map-fields "bad use of syntactic keyword" x x))))) (define-syntax-parameter this-record (lambda (s) @@ -459,7 +464,7 @@ (define-syntax type "This macro lets us query record type info at macro-expansion time." (syntax-case s (map-fields) - ((_ map-fields macro) + ((_ (map-fields _ _) macro) #'(macro (field ...))) (id (identifier? #'id) @@ -595,7 +600,7 @@ (define-syntax match-record-inner #'(let-syntax ((field-offset (syntax-rules () ((_ f) (lookup-field field 0 f))))) - (let* ((offset (type map-fields field-offset)) + (let* ((offset (type (map-fields type match-record) field-offset)) (variable (struct-ref record offset))) (match-record-inner record type (rest ...) body ...)))) ((_ record type (field rest ...) body ...) -- 2.39.2 From unknown Sun Jun 22 00:52:32 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH 0/3] MATCH-RECROD improvements Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 19 May 2023 15:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: "(" Cc: Josselin Poiret , 63135@debbugs.gnu.org Received: via spool by 63135-submit@debbugs.gnu.org id=B63135.16845097813089 (code B ref 63135); Fri, 19 May 2023 15:23:02 +0000 Received: (at 63135) by debbugs.gnu.org; 19 May 2023 15:23:01 +0000 Received: from localhost ([127.0.0.1]:57146 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q01wb-0000ng-9u for submit@debbugs.gnu.org; Fri, 19 May 2023 11:23:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43952) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q01wY-0000nT-Ot for 63135@debbugs.gnu.org; Fri, 19 May 2023 11:22:59 -0400 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 1q01wR-0005Zu-EG; Fri, 19 May 2023 11:22:52 -0400 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=btqeqAe7QjJeMiSz+y/xRgNvyAFynxTbkRXf9A3mCWw=; b=Zn1YQAuPgoHuDgwpwDKK sw6fATgtNGPP0dqmA6rgaK0KxnC2sS9W1nW2p7tm3q0QAm9obfXaaJufxpglvcclMmf72jW2M9wLk SXGP0/hLzh8jd2v6Lf597lwmiSCdEzi99cERlc544Z93tLI4mCGtns30Y4Lo/Lixw2epu3dSNQJvP X+odv4Sl8S9jL2EK9To8ymZqxm/vORAEqXZzHU7xccypL2FYmLKrsC9/jVYv/nazSuf3gJJ+mrDgZ Wh34JnuP9GqAUnIsW1dR2aU7PGe2t/BaTeeCuW4qCnx3TS+PM6q4tn6Sq5je6N7bh6F6DUhbczQgC Od65YNFhAYMUew==; 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 1q01wR-0004bA-1b; Fri, 19 May 2023 11:22:51 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20230428191905.13860-1-paren@disroot.org> <20230428191905.13860-2-paren@disroot.org> Date: Fri, 19 May 2023 17:22:48 +0200 In-Reply-To: <20230428191905.13860-2-paren@disroot.org> (paren@disroot.org's message of "Fri, 28 Apr 2023 20:19:01 +0100") Message-ID: <87h6s8xs53.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-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, Thanks for these much welcome improvements! "(" skribis: > * guix/records.scm (match-record): Raise a human-compherensible syntax er= ror > if the given record type identifier is unbound. [...] > (define-syntax map-fields > (lambda (x) > - (syntax-violation 'map-fields "bad use of syntactic keyword" x x))) > + (syntax-case x () > + ((_ type within) > + (syntax-violation (syntax->datum #'within) > + "undefined guix record-type" > + #'type)) How about =E2=80=9Cinvalid record type identifier=E2=80=9D? (Rule of thumb: never use =E2=80=9CGuix=E2=80=9D in messages and interfaces= .) > - ((_ map-fields macro) > + ((_ (map-fields _ _) macro) > #'(macro (field ...))) > (id > (identifier? #'id) > @@ -595,7 +600,7 @@ (define-syntax match-record-inner > #'(let-syntax ((field-offset (syntax-rules () > ((_ f) > (lookup-field field 0 f))))) > - (let* ((offset (type map-fields field-offset)) > + (let* ((offset (type (map-fields type match-record) field-off= set)) There=E2=80=99s always a tradeoff; not a strong opinion but I=E2=80=99d lea= n towards keeping the macro unchanged (thus a bit simpler) and simply changing the default =E2=80=98syntax-violation=E2=80=99 message above. WDYT? Ludo=E2=80=99. From unknown Sun Jun 22 00:52:32 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH 0/3] MATCH-RECROD improvements Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 19 May 2023 15:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: "(" Cc: Josselin Poiret , 63135@debbugs.gnu.org Received: via spool by 63135-submit@debbugs.gnu.org id=B63135.16845099553406 (code B ref 63135); Fri, 19 May 2023 15:26:01 +0000 Received: (at 63135) by debbugs.gnu.org; 19 May 2023 15:25:55 +0000 Received: from localhost ([127.0.0.1]:57157 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q01zG-0000sd-LS for submit@debbugs.gnu.org; Fri, 19 May 2023 11:25:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39844) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q01zB-0000sJ-K7 for 63135@debbugs.gnu.org; Fri, 19 May 2023 11:25:45 -0400 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 1q01z6-000688-DC; Fri, 19 May 2023 11:25:36 -0400 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=rRWO9Q1BhQneFtzmS9BRVGQeC2U45t0sFBVlGTcKHBo=; b=cbxBhbZ4wkWomNFgjiCC doTgM/V1TKRFosdb18WsE57y7TbPXbc36g9pqnupI5/B4ImvBR6LVRpDLc/zuxyUMxsFlgmZ9PsK7 kMqlUpAVmBpIravlMNpYobKSeJcmDETurX8lagVBFhQKfeM9DI0g6rPa2ebH1CTv2qiaeAmY3MDo2 1t3RdeRpPxaPUTSQx/XHL6+qE/L0+TMvjOuVa4aL0i23ekLDloy7GP5fB30L3WLPq/inGtFusy/T2 I0ZUP04x8/HObpszkFPc1GibrzNAot9LggBbLmwxAeH0YIByDPZU6PTCceBfOE4dzAJJD5GGOOlkP rfYyqS4Qrb5S0w==; 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 1q01z5-0004rn-Rw; Fri, 19 May 2023 11:25:36 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20230428191905.13860-1-paren@disroot.org> <20230428191905.13860-3-paren@disroot.org> Date: Fri, 19 May 2023 17:25:33 +0200 In-Reply-To: <20230428191905.13860-3-paren@disroot.org> (paren@disroot.org's message of "Fri, 28 Apr 2023 20:19:02 +0100") Message-ID: <87cz2wxs0i.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-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.0 (-) "(" skribis: > * guix/records.scm (match-record): Display MATCH-RECORD as the origin of > "unknown record type field" errors. > Show the original MATCH-RECORD form, rather than an intermediate LOOKUP-F= IELD > form, within said errors. [...] > (lambda (s) > "Look up FIELD in the given list and return an expression that repre= sents > its offset in the record. Raise a syntax violation when the field is not > -found." > +found, displaying it as originating in form S*." > (syntax-case s () > - ((_ field offset ()) > - (syntax-violation 'lookup-field "unknown record type field" > - s #'field)) > - ((_ field offset (head tail ...)) > + ((_ s* field offset ()) Maybe =E2=80=98source=E2=80=99 or =E2=80=98form=E2=80=99 rather than =E2=80= =98s*=E2=80=99? Should we add a test in =E2=80=98tests/records.scm=E2=80=99 while we=E2=80= =99re at it? Otherwise LGTM! Ludo=E2=80=99. From unknown Sun Jun 22 00:52:32 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH 0/3] MATCH-RECROD improvements Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 19 May 2023 15:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: "(" Cc: Josselin Poiret , 63135@debbugs.gnu.org Received: via spool by 63135-submit@debbugs.gnu.org id=B63135.16845099683498 (code B ref 63135); Fri, 19 May 2023 15:27:02 +0000 Received: (at 63135) by debbugs.gnu.org; 19 May 2023 15:26:08 +0000 Received: from localhost ([127.0.0.1]:57170 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q01zb-0000uM-Pz for submit@debbugs.gnu.org; Fri, 19 May 2023 11:26:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36700) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q01za-0000tN-Kp for 63135@debbugs.gnu.org; Fri, 19 May 2023 11:26:06 -0400 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 1q01zV-0006CG-Eb; Fri, 19 May 2023 11:26:01 -0400 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=V+mn5mfkL2+iHeLxmGxwKbxGb6VNjUSOJ7QaTv634Cs=; b=J8SwFj5rTo8OvjCVVUGT DPw4VYyAMIFOBrXmUncLrC6UMPQnrtt0vqD2xET03k0svTK+BuF3clM8eG/CrzwB207Ymv9+tgIjh O9625X0NHZzW1gFYqvPJnmP0k7NaP9DKjKYGeDqk5ZJJvC8l8IRryHyR7ynjj3AcX9i6bka2Qz5Oo oXvxV50gQnhExsgivF4vUh3xe1c6DUVl9vVk2NC0AU0Pgcw1brcOhDlnykbVI6qF6jikFzh/0+iGI 8ODh45TRFQqX7FDLHAxzuDM+dp6t3vNSb2B2xQlBsWX0EpsSzTpYck0bL+YZLKFfRFIn7hrWMke9D aBxtJEpfwx2vYQ==; 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 1q01zU-0004zI-W6; Fri, 19 May 2023 11:26:01 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20230428191905.13860-1-paren@disroot.org> <20230428191905.13860-4-paren@disroot.org> Date: Fri, 19 May 2023 17:25:59 +0200 In-Reply-To: <20230428191905.13860-4-paren@disroot.org> (paren@disroot.org's message of "Fri, 28 Apr 2023 20:19:03 +0100") Message-ID: <878rdkxrzs.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) 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 (---) "(" skribis: > * guix/records.scm (match-record): Unwrap matched thunked and delayed fields. > * tests/records.scm ("match-record, thunked field", > "match-record, delayed field"): New tests. Yay! LGTM! From unknown Sun Jun 22 00:52:32 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH 0/3] MATCH-RECROD improvements Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 19 May 2023 15:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: "(" Cc: Josselin Poiret , 63135@debbugs.gnu.org Received: via spool by 63135-submit@debbugs.gnu.org id=B63135.16845100673649 (code B ref 63135); Fri, 19 May 2023 15:28:01 +0000 Received: (at 63135) by debbugs.gnu.org; 19 May 2023 15:27:47 +0000 Received: from localhost ([127.0.0.1]:57176 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q021D-0000wn-51 for submit@debbugs.gnu.org; Fri, 19 May 2023 11:27:47 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42104) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q021A-0000wa-TD for 63135@debbugs.gnu.org; Fri, 19 May 2023 11:27:45 -0400 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 1q0215-0006ZV-N8; Fri, 19 May 2023 11:27:39 -0400 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=8lTF9b2kj24SXa7cIGA4UoBY0wXlEGdTSLjPkyGKtY8=; b=LAm8BU7jfwuOYRvZeVxg 8RPHwMB1bWtuG2dgx+b0tU8jKKUTnPpKYuQvYeZTPqH6ZJTIwxwPoHBPmbUC3d5IHD7p2YFUvIcYu owus+v5QKCPwGMRTh8dBoGmZWKRNZhVf/iHCGjxnrJM/JhqA70lqV1Mp6lvoqEzczQQ2GZfLEff88 2I5Gu6sNF7T5ZUsY9Mjtnl36bgZGleWusZ8ycSZhO80lUdhWYsZgjoP/qjgrD1ZOn3c7M+9jjgLYo BYRUlr2T2h0wt+lhT6UTgtMtCv31mtDmbsMJKxyaxGr4wTGiNbSNWiyiHLlqe/YTnh/YTLqXQIivN s6exVKUfw7GFTg==; 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 1q0215-0005EJ-9l; Fri, 19 May 2023 11:27:39 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20230428191905.13860-1-paren@disroot.org> <20230428191905.13860-5-paren@disroot.org> Date: Fri, 19 May 2023 17:27:37 +0200 In-Reply-To: <20230428191905.13860-5-paren@disroot.org> (paren@disroot.org's message of "Fri, 28 Apr 2023 20:19:04 +0100") Message-ID: <874jo8xrx2.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-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 (---) "(" skribis: > * .dir-locals.el: Treat the fourth form onwards as the body, rather than > the third onwards. Hmm that=E2=80=99s =E2=80=9Cincorrect=E2=80=9D, no? Currently we have: (match-record x (field1 field2 =E2=80=A6) body =E2=80=A6) Do you mean to move the field list on the first line? Ludo=E2=80=99. From unknown Sun Jun 22 00:52:32 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH 0/3] MATCH-RECROD improvements Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 19 May 2023 15:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: "(" Cc: Josselin Poiret , 63135@debbugs.gnu.org Received: via spool by 63135-submit@debbugs.gnu.org id=B63135.16845101293753 (code B ref 63135); Fri, 19 May 2023 15:29:02 +0000 Received: (at 63135) by debbugs.gnu.org; 19 May 2023 15:28:49 +0000 Received: from localhost ([127.0.0.1]:57181 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q022D-0000yT-F3 for submit@debbugs.gnu.org; Fri, 19 May 2023 11:28:49 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42554) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q022B-0000yG-5b for 63135@debbugs.gnu.org; Fri, 19 May 2023 11:28:47 -0400 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 1q0225-0006kw-Ug; Fri, 19 May 2023 11:28:41 -0400 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=dSM8gxzw2GfKNri9OXJESxu9Vmqm7f3E1CWqMXQAtrU=; b=pjsWXpKPzq5Y/bBMNfyd 8rPgfQLujw91vj+Sn8yVnKkHG6DjZYXgSAhXT/SgTvLfKvUxf1Luk7H7z1Vxkp0Q9Nuut/uWZfxfq +qFcJysuJQvUsUcEooGMeoXXVrFLNrzo4+I0pHYU32wYx285btfCiWHAoNb0h4F2Lxd4geAd/ZCQl v1pF/TOT9rTjuPcXv8q5lvv62GPDFCfOA8LITQYTbaWW6h8qANR2LEYhue3p4DH08q+288jYX4n1Y bEVTnlj+B0KEyrS41FnYtxft4pS/G2UZCCiBI7RSBFZx490RelZ6LhwLovK0a6KLbdX+4IvZeBZgE I0JJLt8PKscEcA==; 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 1q021o-0007UT-FD; Fri, 19 May 2023 11:28:36 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20230428191905.13860-1-paren@disroot.org> <20230428191905.13860-6-paren@disroot.org> Date: Fri, 19 May 2023 17:28:23 +0200 In-Reply-To: <20230428191905.13860-6-paren@disroot.org> (paren@disroot.org's message of "Fri, 28 Apr 2023 20:19:05 +0100") Message-ID: <87zg60wdbc.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) 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 (---) "(" skribis: > * guix/records.scm (match-record-lambda): New syntax. > * tests/records.scm ("match-record-lambda"): New test. LGTM! From unknown Sun Jun 22 00:52:32 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH 0/3] MATCH-RECROD improvements Resent-From: "(" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 20 May 2023 18:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: Josselin Poiret , 63135@debbugs.gnu.org Received: via spool by 63135-submit@debbugs.gnu.org id=B63135.16846058762277 (code B ref 63135); Sat, 20 May 2023 18:05:01 +0000 Received: (at 63135) by debbugs.gnu.org; 20 May 2023 18:04:36 +0000 Received: from localhost ([127.0.0.1]:59355 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q0QwW-0000af-7N for submit@debbugs.gnu.org; Sat, 20 May 2023 14:04:36 -0400 Received: from knopi.disroot.org ([178.21.23.139]:58932) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q0QwT-0000aV-H1 for 63135@debbugs.gnu.org; Sat, 20 May 2023 14:04:34 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 3DB8540D25; Sat, 20 May 2023 20:04:32 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Gjdhn_ueNJM2; Sat, 20 May 2023 20:04:31 +0200 (CEST) References: <20230428191905.13860-1-paren@disroot.org> <20230428191905.13860-5-paren@disroot.org> <874jo8xrx2.fsf_-_@gnu.org> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1684605871; bh=t4uUht5LH9RCkJ8sdb1mml/9LYgrgl8AL+A3qC0EF/o=; h=References:From:To:Cc:Subject:Date:In-reply-to; b=iwGlqnLMrvtSPRqoRT5epd0V/W60UyHVdX2eRq/7Yk13UvyfiJ+jQv2XQAkb1qex1 v29qfzQ4hc1zbCAtbwPo4mLSgyGuO3MeLJJAMgc3bFI3cv3IZ7ZSF2GLGC1dOz5onU +YVFIO6gGZdqWhmSVL8od0tCwiVvJo9GFIyEwW3qifGlj4hw1amRSVSI4F/wx8/unJ Oo24DRVrMqGq82i2H7w5Z0b8tqw6zJDJKP/ThyJzGej7K/892I3mKtE0Lq4dFVuQ4y BotIijAqWih9j5bCS8wlvNhDV428Nn/+w5SrCamQ0LEX72B0bYH48nJsH+y9izW09z lKpc2/mifs2EQ== From: "(" Date: Sat, 20 May 2023 19:02:57 +0100 In-reply-to: <874jo8xrx2.fsf_-_@gnu.org> Message-ID: <87mt1ykhg5.fsf@disroot.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) 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.0 (-) Ludovic Court=C3=A8s writes: > Hmm that=E2=80=99s =E2=80=9Cincorrect=E2=80=9D, no? > > Currently we have: > > (match-record x > (field1 field2 =E2=80=A6) > body =E2=80=A6) > > Do you mean to move the field list on the first line? Wait, that's intentional? :) With this change, wouldn't it be: ``` (match-record x (field1 field2) body ...) ``` which seems more in line with how other macros with bodies are typically indented. From unknown Sun Jun 22 00:52:32 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH 0/3] MATCH-RECROD improvements Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 24 May 2023 14:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: "(" Cc: Josselin Poiret , 63135@debbugs.gnu.org Received: via spool by 63135-submit@debbugs.gnu.org id=B63135.168493748511518 (code B ref 63135); Wed, 24 May 2023 14:12:01 +0000 Received: (at 63135) by debbugs.gnu.org; 24 May 2023 14:11:25 +0000 Received: from localhost ([127.0.0.1]:44276 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1pD2-0002zi-OC for submit@debbugs.gnu.org; Wed, 24 May 2023 10:11:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39970) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1pD1-0002zV-8f for 63135@debbugs.gnu.org; Wed, 24 May 2023 10:11:24 -0400 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 1q1pCv-0001jw-Qc; Wed, 24 May 2023 10:11:17 -0400 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=R3lncw7g30lHM5eLpAMaFW7l8cj3Uw0ArGEEvkVmEFc=; b=I1LQn1FtSb29VTN1V0w1 RArSg/fGntEmd1MvhFf6K5/JuzqgRKF3OahLXgp536+4heatMIh2yeerwUjcyTh5+2X64EmqIj5iZ L+iZ/C6aWv8PQ0MobH1lyng3UaErYU6liKdgZpSnHQZ4U+IUNbluYv4HSEMLHyEeZF3kPjCjHO9Kn nlFkTmSQrOlrD3NNBAmgRf0v7zTjJ2SusHsgVi+y9lGhFDKhz6RXcI11wxfPWThUwzSRkfOoc3dkz b1VrpYNVX7NPgrFIdow1zzbhpAMSEFCHUIYKViyS2WHM+YFuKB0fVM1x8FaXwknmboXkgzDLdcmGK TJ64KFcYUITTmw==; 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 1q1pCv-0000Y3-De; Wed, 24 May 2023 10:11:17 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20230428191905.13860-1-paren@disroot.org> <20230428191905.13860-5-paren@disroot.org> <874jo8xrx2.fsf_-_@gnu.org> <87mt1ykhg5.fsf@disroot.org> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Quintidi 5 Prairial an 231 de la =?UTF-8?Q?R=C3=A9volution,?= jour du Canard 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: Wed, 24 May 2023 16:11:15 +0200 In-Reply-To: <87mt1ykhg5.fsf@disroot.org> (paren@disroot.org's message of "Sat, 20 May 2023 19:02:57 +0100") Message-ID: <87o7m9lszg.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-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 (---) "(" skribis: > Ludovic Court=C3=A8s writes: >> Hmm that=E2=80=99s =E2=80=9Cincorrect=E2=80=9D, no? >> >> Currently we have: >> >> (match-record x >> (field1 field2 =E2=80=A6) >> body =E2=80=A6) >> >> Do you mean to move the field list on the first line? > > Wait, that's intentional? :) With this change, wouldn't it be: > > ``` > (match-record x > (field1 field2) > body ...) > ``` > > which seems more in line with how other macros with bodies are typically > indented. Ah! Dunno, to me the version you=E2=80=99re showing here looks =E2=80=9Cle= ss natural=E2=80=9D because it=E2=80=99s a departure from =E2=80=98match=E2=80=99, which was th= e model here. I understand this is all rather subjective=E2=80=A6 Ludo=E2=80=99. From unknown Sun Jun 22 00:52:32 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH 0/3] MATCH-RECROD improvements Resent-From: "(" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 24 May 2023 15:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: Josselin Poiret , 63135@debbugs.gnu.org Received: via spool by 63135-submit@debbugs.gnu.org id=B63135.168494346723241 (code B ref 63135); Wed, 24 May 2023 15:52:02 +0000 Received: (at 63135) by debbugs.gnu.org; 24 May 2023 15:51:07 +0000 Received: from localhost ([127.0.0.1]:44459 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1qlW-00062n-VT for submit@debbugs.gnu.org; Wed, 24 May 2023 11:51:07 -0400 Received: from knopi.disroot.org ([178.21.23.139]:39564) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1qlT-00062a-JD for 63135@debbugs.gnu.org; Wed, 24 May 2023 11:51:06 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 27AC040626; Wed, 24 May 2023 17:51:02 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7kssYLEWWXou; Wed, 24 May 2023 17:51:01 +0200 (CEST) References: <20230428191905.13860-1-paren@disroot.org> <20230428191905.13860-5-paren@disroot.org> <874jo8xrx2.fsf_-_@gnu.org> <87mt1ykhg5.fsf@disroot.org> <87o7m9lszg.fsf@gnu.org> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1684943461; bh=v5s8DQgqmpJ3KAmy/zSRWKXZX6VQZCx0S1K9s3ASn58=; h=References:From:To:Cc:Subject:Date:In-reply-to; b=LGXTP3B2eMpXjQFWEKUOlzF7ua4ngP6j+FdtCdJFJ+dGWK//EPeNhPQeFCvs5+F76 jshpXCujizz4CJdnvqDWRTC3tPI6AjuP8+9X66Mw3vLRl+Z/8NBXfMgA7Trb/DGe2q eb4ickQk4ueya7y+/vpvHjpQWlAvMnTvJeLFFd7dypnQkAYhr3/r2FZHHEyr8pXKV3 4hGUvNwlCm/yjf00asq0QztwY/hmubIohYxp7G89wy8RS5GFlEskvnrnBbYr14eqSZ DDKeby6bFHWpVgP7bkWrTpLY9d+8OJzMUPbWd5ZGhTeEYToxX7TQMYbEIGkXm8TjjL Dcw2OWzuqo0Wg== From: "(" Date: Wed, 24 May 2023 16:49:39 +0100 In-reply-to: <87o7m9lszg.fsf@gnu.org> Message-ID: <87353lhgo0.fsf@disroot.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) 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.0 (-) Ludovic Court=C3=A8s writes: > Ah! Dunno, to me the version you=E2=80=99re showing here looks =E2=80=9C= less natural=E2=80=9D > because it=E2=80=99s a departure from =E2=80=98match=E2=80=99, which was = the model here. > > I understand this is all rather subjective=E2=80=A6 To me, the current indentation conflates the fields expression with the body, which could be confusing for someone who'd never seen a MATCH-RECORD form before. -- ( From unknown Sun Jun 22 00:52:32 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH 0/3] MATCH-RECROD improvements Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 26 May 2023 16:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: "(" Cc: Josselin Poiret , 63135@debbugs.gnu.org Received: via spool by 63135-submit@debbugs.gnu.org id=B63135.168511928013651 (code B ref 63135); Fri, 26 May 2023 16:42:01 +0000 Received: (at 63135) by debbugs.gnu.org; 26 May 2023 16:41:20 +0000 Received: from localhost ([127.0.0.1]:50693 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q2aVE-0003Y7-8b for submit@debbugs.gnu.org; Fri, 26 May 2023 12:41:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39918) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q2aVB-0003Xr-Ib for 63135@debbugs.gnu.org; Fri, 26 May 2023 12:41:18 -0400 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 1q2aV5-0000OM-Rc; Fri, 26 May 2023 12:41:11 -0400 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=Qehs3t1YqzcR0rPLitATddPXx1WRJJwKToZIxyIUzzk=; b=KxqqqxKJz/t5fSSeiXOb 2gJVyip2SH/bAKhvRHXLNt598Ct8Qkftmpprhb0xmWUaaBWKNP2GqFGA1hOCeHvB2zlogf1VDqOzm TmxduDCoueasjbTDjWNOqa279a8uOKw05rUapXfgpx6r0WAVRJ476/BHcCM4UUNE+4TYLI4kL02CD gmrrSfVmghBVwGxPgLOBe+s+YeCgYeCS5Os/G2eDYfaUQj8ayDflKp+cKwgrN/Y2yIIj5gZ4Wq8Xo GKiCaeViAS+jkwwyKkde6Wc/u5+AzAycNP6FMZvP2bXD/vNGGMTM2ma6XT4zv6lYjhMjSD/eXhuNy nGL+cOQQDJqh+g==; 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 1q2aV5-0003jy-FB; Fri, 26 May 2023 12:41:11 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20230428191905.13860-1-paren@disroot.org> <20230428191905.13860-5-paren@disroot.org> <874jo8xrx2.fsf_-_@gnu.org> <87mt1ykhg5.fsf@disroot.org> <87o7m9lszg.fsf@gnu.org> <87353lhgo0.fsf@disroot.org> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Septidi 7 Prairial an 231 de la =?UTF-8?Q?R=C3=A9volution,?= jour du Fromental 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, 26 May 2023 18:41:08 +0200 In-Reply-To: <87353lhgo0.fsf@disroot.org> (paren@disroot.org's message of "Wed, 24 May 2023 16:49:39 +0100") Message-ID: <87pm6nhwpn.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-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, "(" skribis: > Ludovic Court=C3=A8s writes: >> Ah! Dunno, to me the version you=E2=80=99re showing here looks =E2=80= =9Cless natural=E2=80=9D >> because it=E2=80=99s a departure from =E2=80=98match=E2=80=99, which was= the model here. >> >> I understand this is all rather subjective=E2=80=A6 > > To me, the current indentation conflates the fields expression with the > body, which could be confusing for someone who'd never seen a > MATCH-RECORD form before. Hmm yeah, that makes sense. I=E2=80=99m fine with changing then, as long as =E2=80=98.dir-locals.el=E2= =80=99 and (guix read-print) implement the same rule. Ludo=E2=80=99. From unknown Sun Jun 22 00:52:32 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH 0/3] MATCH-RECROD improvements Resent-From: "(" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 27 May 2023 00:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: Josselin Poiret , 63135@debbugs.gnu.org Received: via spool by 63135-submit@debbugs.gnu.org id=B63135.168514896415122 (code B ref 63135); Sat, 27 May 2023 00:57:01 +0000 Received: (at 63135) by debbugs.gnu.org; 27 May 2023 00:56:04 +0000 Received: from localhost ([127.0.0.1]:51070 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q2iE0-0003vo-AQ for submit@debbugs.gnu.org; Fri, 26 May 2023 20:56:04 -0400 Received: from knopi.disroot.org ([178.21.23.139]:41544) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q2iDx-0003v2-JT for 63135@debbugs.gnu.org; Fri, 26 May 2023 20:56:02 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 4273B41D00; Sat, 27 May 2023 02:56:00 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id urhPUd76k6gx; Sat, 27 May 2023 02:55:59 +0200 (CEST) References: <20230428191905.13860-1-paren@disroot.org> <20230428191905.13860-5-paren@disroot.org> <874jo8xrx2.fsf_-_@gnu.org> <87mt1ykhg5.fsf@disroot.org> <87o7m9lszg.fsf@gnu.org> <87353lhgo0.fsf@disroot.org> <87pm6nhwpn.fsf@gnu.org> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1685148959; bh=vFMS9MnCynxxUDn7YAGb+a7xVx2CRXK2gtyFLLoqwVo=; h=References:From:To:Cc:Subject:Date:In-reply-to; b=OrG/6Uwya6w29uKrYhQEDT97wPcYMG54e1rvvtjJCXtvn7s5S+8vN18xqkgPX+9zh 15AG0ETeu+62Gcv3RJhGPHPRTVU6qBZmuF4OMRYr792h98FFoCmU3HHL0MEkJrrfub 03XtVV7PxmLo7ObpwXyXjiW2NjRq3yxC2KWRUd0jtxrSe27YcM2TPlyvg/1bWboOer ViPV6M0t2u/K/I2EupOclQplCfDvxbtd/yEE2/hZ3L5UD1fYNX+latAVxf4MAAhUH5 IZ5zdynPA/zAKDHHTXYS1fLutS1O7FNYRe9MphtWrYYxY1GpauAsWiMcUOL3b5um94 tsPhqa7nezmHA== From: "(" Date: Sat, 27 May 2023 01:55:39 +0100 In-reply-to: <87pm6nhwpn.fsf@gnu.org> Message-ID: <87353i384l.fsf@disroot.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) 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.0 (-) Ludovic Court=C3=A8s writes: > I=E2=80=99m fine with changing then, as long as =E2=80=98.dir-locals.el= =E2=80=99 and (guix > read-print) implement the same rule. Ah, good point :) From unknown Sun Jun 22 00:52:32 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: "(" Subject: bug#63135: closed (Re: [PATCH v2 0/5] MATCH-RECORD improvements) Message-ID: References: <878rczeeze.fsf@jpoiret.xyz> <20230427220452.4972-1-paren@disroot.org> X-Gnu-PR-Message: they-closed 63135 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 63135@debbugs.gnu.org Date: Sun, 04 Jun 2023 09:48:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1685872083-26370-1" This is a multi-part message in MIME format... ------------=_1685872083-26370-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #63135: [PATCH 0/3] MATCH-RECROD improvements which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 63135@debbugs.gnu.org. --=20 63135: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D63135 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1685872083-26370-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 63135-done) by debbugs.gnu.org; 4 Jun 2023 09:47:22 +0000 Received: from localhost ([127.0.0.1]:45070 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5kKY-0006pS-5f for submit@debbugs.gnu.org; Sun, 04 Jun 2023 05:47:22 -0400 Received: from jpoiret.xyz ([206.189.101.64]:56226) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5kKW-0006pJ-Df for 63135-done@debbugs.gnu.org; Sun, 04 Jun 2023 05:47:21 -0400 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 2886A1852FF; Sun, 4 Jun 2023 09:47:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1685872039; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Dy1O84DV5qwKFYAKsGY1tpnccYnHmSpHt8NGW4n41bg=; b=X6dY/b69S+qP+xKX2Z+qVL9H0pwSBBn3kKCTfLLFr1PNK8deAqHAc1aysM3/A/JQJnt4gu Y+83eM9BPBjOTAU4fd0k9A7EFbwSVbZ4Y1gffAwWys+qiFeCD0s/mHsMn/vIaLG9p382S1 N3R57fQs04lvldbMWZZ3EVmAGr2U6iMlh4w18JXeX8Bpt1tntLndwp4NbwwXJ5kAds/HuO GCwevNDJFjjtM5HtuXH6FF+NLk3JlhOaqKEn+w4ALI2wH5/dlzuU0LH0HtizVWoUnam3fq x042ikYv0L1h7M0MJ7ZrLJNteWCLmPnXg1lPfiZNjpapprU5welMxXpKwQsCsw== From: Josselin Poiret To: "(" , 63135-done@debbugs.gnu.org Subject: Re: [PATCH v2 0/5] MATCH-RECORD improvements In-Reply-To: <20230428191905.13860-1-paren@disroot.org> References: <20230428191905.13860-1-paren@disroot.org> Date: Sun, 04 Jun 2023 11:47:17 +0200 Message-ID: <878rczeeze.fsf@jpoiret.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spamd-Bar: / Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63135-done Cc: "\(" 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.0 (/) --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, "(" writes: > This v2 fixes the dir-locals.el file so that it indents MATCH-RECORD > properly and adds a MATCH-RECORD-LAMBDA macro. > > ( (5): > records: match-record: Raise a syntax error if TYPE is nonexistent. > records: match-record: Display more helpful field-not-found error. > records: match-record: Support thunked and delayed fields. > dir-locals: Fix MATCH-RECORD indentation. > records: Add MATCH-RECORD-LAMBDA. > > .dir-locals.el | 3 +- > guix/records.scm | 110 +++++++++++++++++++++++++++++++--------------- > tests/records.scm | 41 +++++++++++++++++ > 3 files changed, 117 insertions(+), 37 deletions(-) Thanks! For some reason your From identity line messed up my patch mangling tools, so I committed with (unmatched-paren instead of just ( as author. Might be the emacs code I'm using that's hitting some corner cases. Pushed as 178ffed3b7fe1784fff67b963c5c4bb667fbad2a with the modifications below (that's a git-range-diff). Basically, I dropped "Display more helpful field-not-found error." since it was causing issues when the body contained an ellipsis, and chose not to display the total form that the error appeared in, but instead attach proper source properties to the field syntax object in a new commit. I also added a test case for match-lambda with an ellipsis in the body, and added match-record-lambda to (guix read-print). 1: b2b374fafa =3D 1: 1a4aace3af records: match-record: Raise a syntax err= or if TYPE is nonexistent. 2: 1b3949cae7 < -: ---------- records: match-record: Display more helpful= field-not-found error. 3: 8def5ef633 ! 2: b88e38d4b5 records: match-record: Support thunked and = delayed fields. @@ guix/records.scm: (define (recutils->alist port) (lambda (s) - "Look up FIELD in the given list and return an expression that re= presents -its offset in the record. Raise a syntax violation when the field is= not --found, displaying it as originating in form S*." +-found." - (syntax-case s () -- ((_ s* field offset ()) +- ((_ field offset ()) +- (syntax-violation 'lookup-field "unknown record type field" + "Look up FIELD in the given list and return both an expression th= at represents +its offset in the record and a procedure that wraps it to return its = \"true\" value +(for instance, FORCE is returned in the case of a delayed field). RE= CORD is passed -+to thunked values. Raise a syntax violation when the field is not fo= und, displaying -+it as originating in form S*." ++to thunked values. Raise a syntax violation when the field is not fo= und." + (syntax-case s (normal delayed thunked) -+ ((_ s* record field offset ()) - (syntax-violation 'match-record - "unknown record type field" - #'s* #'field)) -- ((_ s* field offset (head tail ...)) -+ ((_ s* record field offset ((head normal) tail ...)) ++ ((_ record field offset ()) ++ (syntax-violation 'match-record ++ "unknown record type field" + s #'field)) +- ((_ field offset (head tail ...)) ++ ((_ record field offset ((head normal) tail ...)) + (free-identifier=3D? #'field #'head) + #'(values offset identity)) -+ ((_ s* record field offset ((head delayed) tail ...)) ++ ((_ record field offset ((head delayed) tail ...)) (free-identifier=3D? #'field #'head) - #'offset) -- ((_ s* field offset (_ tail ...)) -- #'(lookup-field s* field (+ 1 offset) (tail ...)))))) +- ((_ field offset (_ tail ...)) +- #'(lookup-field field (+ 1 offset) (tail ...)))))) + #'(values offset force)) -+ ((_ s* record field offset ((head thunked) tail ...)) ++ ((_ record field offset ((head thunked) tail ...)) + (free-identifier=3D? #'field #'head) + #'(values offset (cut <> record))) -+ ((_ s* record field offset (_ tail ...)) -+ #'(lookup-field+wrapper s* record field ++ ((_ record field offset (_ tail ...)) ++ #'(lookup-field+wrapper record field + (+ 1 offset) (tail ...)))))) =20=20=20=20=20=20 (define-syntax match-record-inner (lambda (s) (syntax-case s () - ((_ s* record type ((field variable) rest ...) body ...) + ((_ record type ((field variable) rest ...) body ...) - #'(let-syntax ((field-offset (syntax-rules () - ((_ f) -- (lookup-field s* field 0 f))))) +- (lookup-field field 0 f))))) - (let* ((offset (type (map-fields type match-record) field-= offset)) - (variable (struct-ref record offset))) + #'(let-syntax ((field-offset+wrapper + (syntax-rules () + ((_ f) -+ (lookup-field+wrapper s* record field 0 f))= ))) ++ (lookup-field+wrapper record field 0 f))))) + (let* ((offset wrap (type (map-fields type match-record) + field-offset+wrapper)) + (variable (wrap (struct-ref record offset)))) - (match-record-inner s* record type (rest ...) body ...))= )) - ((_ s* record type (field rest ...) body ...) + (match-record-inner record type (rest ...) body ...)))) + ((_ record type (field rest ...) body ...) ;; Redirect to the canonical form above. @@ guix/records.scm: (define-syntax match-record - (lambda (s) + (syntax-rules () "Bind each FIELD of a RECORD of the given TYPE to it's FIELD name. The order in which fields appear does not matter. A syntax error is = raised if -an unknown field is queried. @@ guix/records.scm: (define-syntax match-record -The current implementation does not support thunked and delayed field= s." - ;; TODO support thunked and delayed fields +an unknown field is queried." - (syntax-case s () - ((_ record type (fields ...) body ...) - #`(if (eq? (struct-vtable record) type) + ((_ record type (fields ...) body ...) + (if (eq? (struct-vtable record) type) + (match-record-inner record type (fields ...) body ...) =20=20=20=20=20 ## tests/records.scm ## @@ tests/records.scm: (define (location-alist loc) 4: 25d001ca8d =3D 3: e6dc1d3996 dir-locals: Fix MATCH-RECORD indentation. 5: 384d6c9562 ! 4: 4cd5293621 records: Add MATCH-RECORD-LAMBDA. @@ .dir-locals.el ;; TODO: Contribute these to Emacs' scheme-mode. (eval . (put 'let-keywords 'scheme-indent-function 3)) =20=20=20=20=20 + ## guix/read-print.scm ## +@@ guix/read-print.scm: (define %special-forms + ('letrec* 2) + ('match 2) + ('match-record 3) ++ ('match-record-lambda 2) + ('when 2) + ('unless 2) + ('package 1) + ## guix/records.scm ## @@ guix/records.scm: (define-module (guix records) alist->record @@ guix/records.scm: (define-module (guix records) ;;; Commentary: ;;; @@ guix/records.scm: (define-syntax match-record - (match-record-inner #,s record type (fields ...) body ..= .) - (throw 'wrong-type-arg record)))))) + (match-record-inner record type (fields ...) body ...) + (throw 'wrong-type-arg record))))) =20=20=20=20=20=20 +(define-syntax match-record-lambda -+ (lambda (s) ++ (syntax-rules () + "Return a procedure accepting a single record of the given TYPE f= or which each +FIELD will be bound to its FIELD name within the returned procedure. = A syntax error +is raised if an unknown field is queried." -+ (syntax-case s () -+ ((_ type (field ...) body ...) -+ #`(lambda (record) -+ (if (eq? (struct-vtable record) type) -+ (match-record-inner #,s record type (field ...) body .= ..) -+ (throw 'wrong-type-arg record))))))) ++ ((_ type (field ...) body ...) ++ (lambda (record) ++ (if (eq? (struct-vtable record) type) ++ (match-record-inner record type (field ...) body ...) ++ (throw 'wrong-type-arg record)))))) + ;;; records.scm ends here =20=20=20=20=20 =2D: ---------- > 5: f045c7ac80 records: match-record: Do not show intern= al form. =2D: ---------- > 6: 178ffed3b7 tests: records: Add test for ellipsis in = body. =2D-=20 Josselin Poiret --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQHEBAEBCgAuFiEEOSSM2EHGPMM23K8vUF5AuRYXGooFAmR8XaUQHGRldkBqcG9p cmV0Lnh5egAKCRBQXkC5FhcaiiqdDACzw0Zo+U4MSZDB/+npEQekhFdhwHHiJT1Q 8dhvp2OTCNcBlnyx8vg2KEqz+OmCAmD3En+r8yH3EJdILyMomKsHVtNmmxwgQW7H g1GTd0lbeoy9tXqOwwutxUkWfh7l2gXBwNQlJ2taHneNZKSmoxabFMRMa4Py9S9V 93a6K/zCAyYXcTK1OgEgWKgkoIgOMqqr6sghpxVRcewwHF2o6Y+YSgUbdkQM1rQE MV7rsrvNdJUdwY68pcUuXy07lagXfkKODMoO1Laj8WBJThAxLxEZd2xej6BSXjWg lIghPWnYgndBzV+26zKk8EPM7OISrg4yIi3Lc9CZGZ8TtrPThSciEnr+iT6zgWFY oEXBnyRK9LFnTjVdMYBDrmqSW9xxzlobaFWAMFN9+ZPl1UT1Inrb0gbGtPC4zpHN 0JSj/K/B8KkkEYg0ERODcEr5zW9PfNCymcgpZ7eDj8RFREBm4AxpKyyd7hjV3cU6 QNzbR11VLA/xQ6kl4oH1GJ7R8kVbL68= =uaXt -----END PGP SIGNATURE----- --=-=-=-- ------------=_1685872083-26370-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 27 Apr 2023 22:05:16 +0000 Received: from localhost ([127.0.0.1]:59965 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ps9jo-0000fa-5L for submit@debbugs.gnu.org; Thu, 27 Apr 2023 18:05:16 -0400 Received: from lists.gnu.org ([209.51.188.17]:43472) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ps9jj-0000fO-GL for submit@debbugs.gnu.org; Thu, 27 Apr 2023 18:05:14 -0400 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 1ps9jj-0004y4-8f for guix-patches@gnu.org; Thu, 27 Apr 2023 18:05:11 -0400 Received: from knopi.disroot.org ([178.21.23.139]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ps9jf-0006wZ-Nx for guix-patches@gnu.org; Thu, 27 Apr 2023 18:05:10 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id EE92440303; Fri, 28 Apr 2023 00:05:03 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zWs4bkZUHxJc; Fri, 28 Apr 2023 00:05:02 +0200 (CEST) From: "(" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1682633102; bh=eHd5bua0xa0E0ekYgEN2ZXU4shzb2CGBu2998xIQ2IE=; h=From:To:Cc:Subject:Date; b=kqy7MIA64H4ewjtlyAJjDSU5Me0gH92bF/SzZtMqYxQwOPsOeQQlfL2KbgzADJWqH p3eE4TmwicvKhepgz3A8vb69lQ1Hq//6rfbGMXrknTpzHv/ldNSJ169LbVmOjDl+dz WEwzSBOgzK26LR4zfzYTIExt/Htm8k4BFvdXMJzkf3A9lskLZabB5o7jqleSU0hwlm 2okn0LwKMIC0ZJpgSWgW6bw9QuTiCDUVPW9ZoPYo+JBOonte4KkTHwfhDCARC6R0rl cvQyK0dh7ctJMwW9bxN8Wjgl75z0UWYOujc1ohQ89cHQjZASaZp/S8Ya6shsdYhwbU j0waBoPq9hQUA== To: guix-patches@gnu.org Subject: [PATCH 0/3] MATCH-RECROD improvements Date: Thu, 27 Apr 2023 23:04:49 +0100 Message-Id: <20230427220452.4972-1-paren@disroot.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=178.21.23.139; envelope-from=paren@disroot.org; helo=knopi.disroot.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit Cc: "\(" , Josselin Poiret 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.4 (--) Hello Guix, Here are three patches pertaining to MATCH-RECORD; the first mostly by Josselin Poiret, with modifications, and the latter two by me. The former two improve MATCH-RECORD's error reporting, and the last removes a TODO by adding support in MATCH-RECORD for unpacking the values of fields marked THUNKED and DELAYED! -- ( ( (3): records: match-record: Raise a syntax error if TYPE is nonexistent. records: match-record: Display more helpful field-not-found error. records: match-record: Support thunked and delayed fields. guix/records.scm | 95 ++++++++++++++++++++++++++++++----------------- tests/records.scm | 29 +++++++++++++++ 2 files changed, 89 insertions(+), 35 deletions(-) -- 2.39.2 ------------=_1685872083-26370-1-- From unknown Sun Jun 22 00:52:32 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH v2 0/5] MATCH-RECORD improvements Resent-From: Josselin Poiret Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 04 Jun 2023 10:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: "(" , 63135-done@debbugs.gnu.org Cc: "\(" Received: via spool by 63135-done@debbugs.gnu.org id=D63135.168587573410325 (code D ref 63135); Sun, 04 Jun 2023 10:49:02 +0000 Received: (at 63135-done) by debbugs.gnu.org; 4 Jun 2023 10:48:54 +0000 Received: from localhost ([127.0.0.1]:45146 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5lI6-0002gS-0L for submit@debbugs.gnu.org; Sun, 04 Jun 2023 06:48:54 -0400 Received: from jpoiret.xyz ([206.189.101.64]:60758) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5lI3-0002gB-8O for 63135-done@debbugs.gnu.org; Sun, 04 Jun 2023 06:48:52 -0400 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 25E0118540C; Sun, 4 Jun 2023 10:48:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1685875729; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Qy3YuxYv2G1AuPAUZBLfOvMi4rst0LJhxApTxhi/hAU=; b=VIhF+vCBK1FFou7B5Pvqh2Ta1kMFpBXWwmfIwbitIPeI/Q1Ht4nQxFh6JDc4K0CBXRI7QF IcGJTR0gEulC2s6jbTtC+86G4lfNJ/1WEEwJcaQQg5qhjiv6f84LevcFjbzhJbzBHDEUfM jw2fS1LpTm5XNoc2SeexO+2tHO15pCOsPhi64t0AkAvf2qx9uhw/T6dA3P3XdIbEOg+9kc 9v22WfDqBdybHfBIMqIyKwCNO8G8C+G+/ZvQih2l2e1aep5X3Svsa67daxjDoBg/d/LOAJ uVtdeP7c8sMYawFFAuIuls+oOIt7r+T9Eb8yXQcwbNjJpxnhhmrs8l98BljbOw== From: Josselin Poiret In-Reply-To: <878rczeeze.fsf@jpoiret.xyz> References: <20230428191905.13860-1-paren@disroot.org> <878rczeeze.fsf@jpoiret.xyz> Date: Sun, 04 Jun 2023 12:48:46 +0200 Message-ID: <87ilc3y035.fsf@jpoiret.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spamd-Bar: / Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spam-Score: 0.0 (/) 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.0 (/) --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi again, Josselin Poiret writes: > For some reason your From identity line messed up my patch mangling > tools, so I committed with (unmatched-paren instead of just ( as author. > Might be the emacs code I'm using that's hitting some corner cases. Just a heads-up, looking at the log on cgit made me realize that most of the commits have a messed up author (still includes (unmatched-paren , but also some extra stuff). Apologies! I'll try to double check that in the future. Best, =2D-=20 Josselin Poiret --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQHEBAEBCgAuFiEEOSSM2EHGPMM23K8vUF5AuRYXGooFAmR8bA4QHGRldkBqcG9p cmV0Lnh5egAKCRBQXkC5FhcaijwaC/9KWwF0FVyxv4pgU8TwbtiqDWhCkopZ63Cn B02VB7ruJoIbkNCgDaryBCckcEPQC1/FdkNrb9T4XDcqvJWFuhgn8M/s7vO/oJQg ZnT0nfIdy3Xt5AcJ/0vAnKRk+zYCnufK5C8dP+fK7hSgJ8ryVL5nr0qknWOzBGOZ 31HmMFodurk+bTrnbfhmXfq+DZGqsVrtG7IYfmZ8SsTkjG90VkyQ+3Kq5y9LHsI2 h1z6nZhSmLeQ9B9/PDp+rJWybzvqxZbN9AOTaBzH+1AYNJrP6KgKp391+tuVXXr+ +urFk/RoB117Y9i073u5RZsLnaB4JKt9xuVlND4aexYMseytToQH1c5YEygc+/OZ yJolpjiFYeFVjtjLSZH6jyouwL2I/mIy85GJbBq4qiHZ29PPkdIyW1aSGCecEcLB BFA5JDCiVrizfVlUzW4ZC5FbsZvJhBE4nuSM8681X5YXaVn21Bpz7uSyDxjTbAbT iQlBFBbrcASmSj1mQ1XhR8PboNxArag= =qfZ8 -----END PGP SIGNATURE----- --=-=-=-- From unknown Sun Jun 22 00:52:32 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63135] [PATCH v2 0/5] MATCH-RECORD improvements Resent-From: "(" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 04 Jun 2023 19:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63135 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Josselin Poiret Cc: 63135-done@debbugs.gnu.org Received: via spool by 63135-done@debbugs.gnu.org id=D63135.168590589213481 (code D ref 63135); Sun, 04 Jun 2023 19:12:02 +0000 Received: (at 63135-done) by debbugs.gnu.org; 4 Jun 2023 19:11:32 +0000 Received: from localhost ([127.0.0.1]:47382 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5t8W-0003VN-HR for submit@debbugs.gnu.org; Sun, 04 Jun 2023 15:11:32 -0400 Received: from knopi.disroot.org ([178.21.23.139]:58896) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5t8U-0003V7-NX for 63135-done@debbugs.gnu.org; Sun, 04 Jun 2023 15:11:32 -0400 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id BE49D40600; Sun, 4 Jun 2023 21:11:25 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dzhOM-ImIyK1; Sun, 4 Jun 2023 21:11:24 +0200 (CEST) References: <20230428191905.13860-1-paren@disroot.org> <878rczeeze.fsf@jpoiret.xyz> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1685905884; bh=SFeKnPMC6Jth3uk2rZsFo3iB4OfFgYk+naajFWZ9k3Q=; h=References:From:To:Cc:Subject:Date:In-reply-to; b=Jsx0KJAAKhd90x/gNyqBBZzYMdN8YjgPlClUB/MOBEtgAJqZ2E9E/iPUdZ7BDoWU+ 4llD6sKBtT5ynD1YD9dJ7E68O7MMc2V0ajQKnISl4BzdKapv3feUlq0iLKI5GS6drL wkuLT59I3VLN5VX9RDsrQWnb4YpqVEhuw8148W/7A08GkGHLqRIWUB9weGE6QdHRD9 MrX1Xo6BRMyNJipQyks59SM3J7BcTMAGQDI0OsQ0FeuJie06ZeuI4ce1ho6DbpnPHj dL7Yr9Y32/vanpC+pwJXtHlgc95lswNJjjgCFWMTIamJKKQDejajzP2iU1bDwwR75D ApkELXqg4a+3A== From: "(" Date: Sun, 04 Jun 2023 20:11:04 +0100 In-reply-to: <878rczeeze.fsf@jpoiret.xyz> Message-ID: <87bkhvqbzc.fsf@disroot.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) 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.0 (-) Josselin Poiret writes: > Thanks! Reciprocated! :D -- (