[bug#54674] services: configuration: Use *unspecified* instead of 'disabled.
Commit Message
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.
Comments
i don't want to be pushy, but some changes that i wish i could publish is held back by the fate of this patchset (https://github.com/attila-lendvai/guix-crypto/commits/staging). hence i wish there was some progress on this, and i'm willing to do whatever may help the process (e.g. writing some more tests?).
i'd be satisfied with a simple promise that it's already being investigated/tested, or even with a rejection that this is not the right direction and it probably won't be accepted. it would be disappointing, but then i could refactor my channel to work with the current guix proper codebase and publish it.
--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“Keep things as simple as you can, but no simpler.”
— Albert Einstein (1879–1955), variations: things/explanation; Einstein/Occam
@@ -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)))