From: Attila Lendvai <attila@lendvai.name>
To: 54652@debbugs.gnu.org
Cc: Attila Lendvai <attila@lendvai.name>
Subject: [bug#54652] [PATCH 2/2] guix: MATCH-RECORD supports (FIELD-NAME VARIABLE-NAME) forms.
Date: Thu, 31 Mar 2022 14:52:31 +0200 [thread overview]
Message-ID: <20220331125230.4388-2-attila@lendvai.name> (raw)
In-Reply-To: <20220331124657.2985-1-attila@lendvai.name>
E.g. (match-record obj <type> (field1 (field2 var-name)) ...)
* guix/records.scm (match-record/fields): Implement it.
---
a real world example i was facing: a field name is the same
as an object constructor, and thus shadows it in a
match-record form, unless a different variable name is chosen.
guix/records.scm | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/guix/records.scm b/guix/records.scm
index e311086d73..492ab2aed6 100644
--- a/guix/records.scm
+++ b/guix/records.scm
@@ -537,12 +537,15 @@ (define (recutils->alist port)
(define-syntax match-record/fields
(syntax-rules ()
- ((_ record type (field fields ...) body ...)
- (let ((field ((record-accessor type 'field) record)))
+ ((_ record type ((field-name variable-name) fields ...) body ...)
+ (let ((variable-name ((record-accessor type 'field-name) 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 (field fields ...) body ...)
+ ;; Channel it back into the canonical form above.
+ (match-record/fields record type ((field field) fields ...) body ...))
((_ record type () body ...)
(begin body ...))))
--
2.34.0
next prev parent reply other threads:[~2022-03-31 12:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-31 12:46 [bug#54652] [PATCH 1/2] guix: Only check the object type once in the MATCH-RECORD expansion Attila Lendvai
2022-03-31 12:52 ` Attila Lendvai [this message]
2022-06-30 13:56 ` [bug#54652] (No Subject) Attila Lendvai
2022-11-20 14:18 ` bug#54652: " Attila Lendvai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220331125230.4388-2-attila@lendvai.name \
--to=attila@lendvai.name \
--cc=54652@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).