GNU bug report logs - #54652
[PATCH 1/2] guix: Only check the object type once in the MATCH-RECORD expansion.

Previous Next

Package: guix-patches;

Reported by: Attila Lendvai <attila <at> lendvai.name>

Date: Thu, 31 Mar 2022 12:49:01 UTC

Severity: normal

Tags: patch

Done: Attila Lendvai <attila <at> lendvai.name>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Attila Lendvai <attila <at> lendvai.name>
Subject: bug#54652: closed ((No Subject))
Date: Sun, 20 Nov 2022 14:19:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#54652: [PATCH 1/2] guix: Only check the object type once in the MATCH-RECORD expansion.

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 54652 <at> debbugs.gnu.org.

-- 
54652: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=54652
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Attila Lendvai <attila <at> lendvai.name>
To: "54652-close <at> debbugs.gnu.org" <54652-close <at> debbugs.gnu.org>
Subject: (No Subject)
Date: Sun, 20 Nov 2022 14:18:11 +0000
closing, it was superseded by #59390

https://issues.guix.gnu.org/59390

-- 
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“Personal dishonesty is not needed to produce a dishonest business plan or research proposal. Wishful thinking suffices.”
	— John McCarthy (1927–2011), father of Lisp


[Message part 3 (message/rfc822, inline)]
From: Attila Lendvai <attila <at> lendvai.name>
To: guix-patches <at> gnu.org
Cc: Attila Lendvai <attila <at> lendvai.name>
Subject: [PATCH 1/2] guix: Only check the object type once in the MATCH-RECORD
 expansion.
Date: Thu, 31 Mar 2022 14:46:57 +0200
* guix/records.scm (match-record/fields): New macro.
(match-record): Only check the object type once in the expansion.
---
 guix/records.scm | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/guix/records.scm b/guix/records.scm
index ed94c83dac..e311086d73 100644
--- a/guix/records.scm
+++ b/guix/records.scm
@@ -535,17 +535,25 @@ (define (recutils->alist port)
               (else
                (error "unmatched line" line))))))))
 
+(define-syntax match-record/fields
+  (syntax-rules ()
+    ((_ record type (field fields ...) body ...)
+     (let ((field ((record-accessor type 'field) record)))
+       ;; TODO compute indices and report wrong-field-name errors at
+       ;;      expansion time
+       ;; TODO support thunked and delayed fields
+       (match-record/fields record type (fields ...) body ...)))
+    ((_ record type () body ...)
+     (begin body ...))))
+
 (define-syntax match-record
   (syntax-rules ()
     "Bind each FIELD of a RECORD of the given TYPE to it's FIELD name.
 The current implementation does not support thunked and delayed fields."
     ((_ record type (field fields ...) body ...)
      (if (eq? (struct-vtable record) type)
-         ;; TODO compute indices and report wrong-field-name errors at
-         ;;      expansion time
-         ;; TODO support thunked and delayed fields
-         (let ((field ((record-accessor type 'field) record)))
-           (match-record record type (fields ...) body ...))
+         ;; So that we only test the type once.
+         (match-record/fields record type (field fields ...) body ...)
          (throw 'wrong-type-arg record)))
     ((_ record type () body ...)
      (begin body ...))))
-- 
2.34.0




This bug report was last modified 2 years and 183 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.