all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Attila Lendvai <attila@lendvai.name>
To: Maxime Devos <maximedevos@telenet.be>
Cc: 54674@debbugs.gnu.org
Subject: [bug#54674] [PATCH] services: configuration: Use *unspecified* instead of 'disabled.
Date: Mon, 04 Apr 2022 07:46:15 +0000	[thread overview]
Message-ID: <RyjP_EnJExOZtmPhVCyaItCm7UL0vmEX6dksmALrBGXALN_VruCqiFyWM0MqmBflw_zwb1ZJ97WO4SjbAY_Hn97vgotOpY3bwntDDxkAov0=@lendvai.name> (raw)
In-Reply-To: <2f39bf8cd56b3019026e43532b2f7b937de99b7e.camel@telenet.be>

[-- Attachment #1: Type: text/plain, Size: 1163 bytes --]

> > the reason i didn't do the (field1 maybe-string "") syntax *i.e. no
> > parens around maybe-string), is that i couldn't convince the hygienic
> > macro system about it.
>
> Do you have some non-working code? Maybe I can make it work ...

thank you for your kind offer Maxime! i have attached a half-baked patch.

it should also resolve your other nice catch of my mistaken use of UNSPECIFIED? on syntax objects.

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.

the solution is probably in the direction of introducing a new DEFINE-CONFIGURATION-HELPER/FIELD somehow, but hygienic macros are a rather new territory for me...

as for the (threads (number 5)) change: i'd rather not do it in this commit to try to keep it as much idempotent wrt behavior as possible.

--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“The important thing is to not stop questioning. Curiosity has its own reason for existing.”
	— Albert Einstein (1879–1955)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-WIP-define-configuration-accepts-field1-maybe-string-forms.patch --]
[-- Type: text/x-patch; name=0001-WIP-define-configuration-accepts-field1-maybe-string-forms.patch, Size: 3761 bytes --]

diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 325ef6e0ac..28dc314301 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -165,7 +165,7 @@ (define-maybe stem (no-serialization)))
 
 (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 ...) ...)
      (with-syntax (((field-getter ...)
                     (map (lambda (field)
                            (id #'stem #'stem #'- field))
@@ -205,9 +205,7 @@ (define-record-type* #,(id #'stem #'< #'stem #'>)
     					source-properties->location))
     			(innate))
     	     #,@(map (lambda (name getter def)
-    		       (if (unspecified? (syntax->datum def))
-    			   #`(#,name #,getter)
-    			   #`(#,name #,getter (default #,def))))
+    		       #`(#,name #,getter (default #,def)))
     		     #'(field ...)
     		     #'(field-getter ...)
     		     #'(field-default ...)))
@@ -231,7 +229,13 @@ (define-syntax-rule (stem arg (... ...))
     	     (let ((conf (#,(id #'stem #'% #'stem) arg (... ...))))
     	       (validate-configuration conf
     				       #,(id #'stem #'stem #'-fields))
-    	       conf)))))))
+    	       conf)))))
+    ;; TODO This does not work, because it matches when *every* field is of
+    ;; this form.
+    ((_ stem (field (field-type) doc custom-serializer ...) ...)
+     (stem (field (field-type *unspecified*) doc custom-serializer ...) ...))
+    ((_ stem (field field-type doc custom-serializer ...) ...)
+     (stem (field (field-type *unspecified*) doc custom-serializer ...) ...))))
 
 (define no-serialization         ;syntactic keyword for 'define-configuration'
   '(no serialization))
@@ -239,27 +243,19 @@ (define no-serialization         ;syntactic keyword for 'define-configuration'
 (define-syntax define-configuration
   (lambda (s)
     (syntax-case s (no-serialization prefix)
-      ((_ stem (field (field-type def ...) doc custom-serializer ...) ...
-          (no-serialization))
-       (define-configuration-helper
-         #f #f #'(_ 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 ...)
-                                                 doc custom-serializer ...)
-                 ...)))
-      ((_ stem (field (field-type def ...) doc custom-serializer ...) ...)
-       (define-configuration-helper
-         #t #f #'(_ stem (field (field-type def ...) doc custom-serializer ...)
-                 ...))))))
+      ((_ stem fields ... (no-serialization))
+       (define-configuration-helper #f #f
+         #'(_ stem fields ...)))
+      ((_ stem fields ... (prefix serializer-prefix))
+       (define-configuration-helper #t #'serializer-prefix
+         #'(_ stem fields ...)))
+      ((_ stem fields ...)
+       (define-configuration-helper #t #f
+         #'(_ stem fields ...))))))
 
 (define-syntax-rule (define-configuration/no-serialization
-                      stem (field (field-type def ...)
-                                  doc custom-serializer ...) ...)
-  (define-configuration stem (field (field-type def ...)
-                                    doc custom-serializer ...) ...
+                      stem (field type-and-def doc custom-serializer ...) ...)
+  (define-configuration stem (field type-and-def doc custom-serializer ...) ...
     (no-serialization)))
 
 (define (empty-serializer field-name val) "")

  reply	other threads:[~2022-04-04  7:49 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 [this message]
2022-04-04 11:25     ` Maxime Devos
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='RyjP_EnJExOZtmPhVCyaItCm7UL0vmEX6dksmALrBGXALN_VruCqiFyWM0MqmBflw_zwb1ZJ97WO4SjbAY_Hn97vgotOpY3bwntDDxkAov0=@lendvai.name' \
    --to=attila@lendvai.name \
    --cc=54674@debbugs.gnu.org \
    --cc=maximedevos@telenet.be \
    /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.