GNU bug report logs -
#60225
[PATCH] records: match-record supports specifying a different variable name.
Previous Next
Reported by: Attila Lendvai <attila <at> lendvai.name>
Date: Tue, 20 Dec 2022 17:42:02 UTC
Severity: normal
Tags: patch
Done: Ludovic Courtès <ludo <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Tue, 27 Dec 2022 23:49:36 +0100
with message-id <87wn6ca2db.fsf_-_ <at> gnu.org>
and subject line Re: bug#60225: [PATCH] records: match-record supports specifying a different variable name.
has caused the debbugs.gnu.org bug report #60225,
regarding [PATCH] records: match-record supports specifying a different variable name.
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
60225: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60225
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
An example:
(match-record obj <my-type>
(field1 (field2 custom-var-name) field3)
...)
---
guix/records.scm | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/guix/records.scm b/guix/records.scm
index 13463647c8..0b2487a156 100644
--- a/guix/records.scm
+++ b/guix/records.scm
@@ -592,13 +592,16 @@ (define-syntax lookup-field
(define-syntax match-record-inner
(lambda (s)
(syntax-case s ()
- ((_ record type (field rest ...) body ...)
- #`(let-syntax ((field-offset (syntax-rules ()
+ ((_ record type ((field-name variable-name) rest ...) body ...)
+ #'(let-syntax ((field-offset (syntax-rules ()
((_ f)
- (lookup-field field 0 f)))))
+ (lookup-field field-name 0 f)))))
(let* ((offset (type map-fields field-offset))
- (field (struct-ref record offset)))
+ (variable-name (struct-ref record offset)))
(match-record-inner record type (rest ...) body ...))))
+ ((_ record type (field rest ...) body ...)
+ ;; Redirect to the canonical form above.
+ #'(match-record-inner record type ((field field) rest ...) body ...))
((_ record type () body ...)
#'(begin body ...)))))
--
2.35.1
[Message part 3 (message/rfc822, inline)]
Hi,
Attila Lendvai <attila <at> lendvai.name> skribis:
> An example:
>
> (match-record obj <my-type>
> (field1 (field2 custom-var-name) field3)
> ...)
>
> * guix/records.scm (match-record-inner): Add support for the new syntax.
> * tests/records.scm ("match-record, simple"): Add a simple test case for the
> new syntax.
Applied, thanks!
Ludo’.
This bug report was last modified 2 years and 147 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.