From: Maxime Devos <maximedevos@telenet.be>
To: Attila Lendvai <attila@lendvai.name>
Cc: 54674@debbugs.gnu.org
Subject: [bug#54674] [PATCH] services: configuration: Use *unspecified* instead of 'disabled.
Date: Mon, 04 Apr 2022 13:25:11 +0200 [thread overview]
Message-ID: <bcaab1bbb79a6cd3d4503f5f57f4ef7eb20cb52f.camel@telenet.be> (raw)
In-Reply-To: <RyjP_EnJExOZtmPhVCyaItCm7UL0vmEX6dksmALrBGXALN_VruCqiFyWM0MqmBflw_zwb1ZJ97WO4SjbAY_Hn97vgotOpY3bwntDDxkAov0=@lendvai.name>
[-- Attachment #1.1: Type: text/plain, Size: 435 bytes --]
Attila Lendvai schreef op ma 04-04-2022 om 07:46 [+0000]:
> in this change i try to introduce a codepath for a canonical form for
> DEFINE-CONFIGURATION fields, but it won't work this way, because this
> way the SYNTAX-CASE forms will only match when *every* field is of
> the specified shape.
See attachement for poposed solution. (Not done: *unspecified* instead
of the symbol 'disabled' as default).
Greetings,
Maxime.
[-- Attachment #1.2: Type: text/x-patch, Size: 3657 bytes --]
diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 0de350a4df..06bb73c9fa 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -5,6 +5,7 @@
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
+;;; Copyright © 2022 Maxime Devos <maximedevos@telenet.be>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -162,9 +163,21 @@ does not have a default value" field kind)))
(define-syntax-rule (define-maybe/no-serialization stem)
(define-maybe stem (no-serialization)))
+(define (analyse-field-type+def s)
+ (syntax-case s ()
+ ((field-type def ...)
+ (identifier? #'field-type)
+ (values #'(field-type def ...)))
+ (field-type
+ (identifier? #'field-type)
+ (values #'(field-type)))))
+
(define (define-configuration-helper serialize? serializer-prefix syn)
(syntax-case syn ()
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...)
+ ((_ stem (field field-type+def doc custom-serializer ...) ...)
+ ;; TODO: fix indentation, maybe with-syntax*?
+ (with-syntax ((((field-type def ...) ...)
+ (map analyse-field-type+def #'(field-type+def ...))))
(with-syntax (((field-getter ...)
(map (lambda (field)
(id #'stem #'stem #'- field))
@@ -233,7 +246,7 @@ does not have a default value" field kind)))
(let ((conf (#,(id #'stem #'% #'stem) arg (... ...))))
(validate-configuration conf
#,(id #'stem #'stem #'-fields))
- conf)))))))
+ conf))))))))
(define no-serialization ;syntactic keyword for 'define-configuration'
'(no serialization))
@@ -241,26 +254,26 @@ does not have a default value" field kind)))
(define-syntax define-configuration
(lambda (s)
(syntax-case s (no-serialization prefix)
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...
+ ((_ stem (field field-type+def doc custom-serializer ...) ...
(no-serialization))
(define-configuration-helper
- #f #f #'(_ stem (field (field-type def ...) doc custom-serializer ...)
+ #f #f #'(_ stem (field field-type+def doc custom-serializer ...)
...)))
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...
+ ((_ stem (field field-type+def doc custom-serializer ...) ...
(prefix serializer-prefix))
(define-configuration-helper
- #t #'serializer-prefix #'(_ stem (field (field-type def ...)
+ #t #'serializer-prefix #'(_ stem (field field-type+def
doc custom-serializer ...)
...)))
- ((_ stem (field (field-type def ...) doc custom-serializer ...) ...)
+ ((_ stem (field field-type+def doc custom-serializer ...) ...)
(define-configuration-helper
- #t #f #'(_ stem (field (field-type def ...) doc custom-serializer ...)
+ #t #f #'(_ stem (field field-type+def doc custom-serializer ...)
...))))))
(define-syntax-rule (define-configuration/no-serialization
- stem (field (field-type def ...)
+ stem (field field-type+def
doc custom-serializer ...) ...)
- (define-configuration stem (field (field-type def ...)
+ (define-configuration stem (field field-type+def
doc custom-serializer ...) ...
(no-serialization)))
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]
next prev parent reply other threads:[~2022-04-04 11:26 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-01 19:19 [bug#54674] [PATCH] services: configuration: Use *unspecified* instead of 'disabled Attila Lendvai
2022-04-01 19:46 ` Maxime Devos
2022-04-01 19:56 ` Maxime Devos
2022-04-01 19:58 ` Maxime Devos
2022-04-04 7:46 ` Attila Lendvai
2022-04-04 11:25 ` Maxime Devos [this message]
2022-04-18 9:26 ` Attila Lendvai
2022-04-07 13:52 ` [bug#54674] [PATCH v2 1/2] services: configuration: Support (field1 maybe-number "") format Attila Lendvai
2022-04-07 13:52 ` [bug#54674] [PATCH v2 2/2] services: configuration: Use *unspecified* instead of 'disabled Attila Lendvai
2022-04-07 15:01 ` [bug#54674] [PATCH v3 1/2] services: configuration: Support (field1 maybe-number "") format Attila Lendvai
2022-04-07 15:01 ` [bug#54674] [PATCH v3 2/2] services: configuration: Use *unspecified* instead of 'disabled Attila Lendvai
2022-04-20 9:15 ` [bug#54674] [PATCH v4 1/2] services: configuration: Support (field1 maybe-number "") format Attila Lendvai
2022-04-20 9:15 ` [bug#54674] [PATCH v4 2/2] services: configuration: Use *unspecified* instead of 'disabled Attila Lendvai
2022-04-23 14:55 ` [bug#54674] [PATCH v4 1/2] services: configuration: Support (field1 maybe-number "") format Maxime Devos
2022-05-17 11:38 ` Attila Lendvai
2022-05-17 16:15 ` Maxime Devos
2022-05-19 14:21 ` Attila Lendvai
2022-05-19 20:41 ` Attila Lendvai
2022-04-24 22:41 ` [bug#54674] [PATCH] doc: Follow the 'disabled -> *unspecified* configuration refactor Attila Lendvai
2022-05-17 11:39 ` [bug#54674] [PATCH v5 1/3] services: configuration: Support (field1 maybe-number "") format Attila Lendvai
2022-05-17 11:39 ` [bug#54674] [PATCH v5 2/3] services: configuration: Use *unspecified* instead of 'disabled Attila Lendvai
2022-05-17 11:39 ` [bug#54674] [PATCH v5 3/3] doc: Follow the 'disabled -> *unspecified* configuration refactor Attila Lendvai
2022-06-14 22:31 ` bug#54674: [PATCH] services: configuration: Use *unspecified* instead of 'disabled Ludovic Courtès
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bcaab1bbb79a6cd3d4503f5f57f4ef7eb20cb52f.camel@telenet.be \
--to=maximedevos@telenet.be \
--cc=54674@debbugs.gnu.org \
--cc=attila@lendvai.name \
/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 external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.