GNU bug report logs -
#49812
[PATCH] services: In MODIFY-SERVICES macro allow specifying a service by its name.
Previous Next
Reported by: Brice Waegeneire <brice <at> waegenei.re>
Date: Sun, 1 Aug 2021 21:04:02 UTC
Severity: normal
Tags: patch, wontfix
Done: Ludovic Courtès <ludo <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 49812 <at> debbugs.gnu.org (full text, mbox):
Hi,
Brice Waegeneire <brice <at> waegenei.re> skribis:
> This is specially useful with any services singleton created with
> 'simple-service' such as 'set-xorg-configuration'.
Could you show an example? Services created by ‘simple-service’ &
co. are effectively anonymous; it’s a bit like a lambda.
> * doc/guix.texi (Service Reference)[modify-services]: Document support
> for specifying service by its name.
> * gnu/services.scm (modify-services): Support specifying a service by
> its name in addition to its type.
[...]
> +++ b/gnu/services.scm
> @@ -303,8 +303,9 @@ singleton service type NAME, of which the returned service is an instance."
> (%modify-service svc clauses ...)))
> ((_ service)
> service)
> - ((_ svc (kind param => exp ...) clauses ...)
> - (if (eq? (service-kind svc) kind)
> + ((_ svc (kind-or-name param => exp ...) clauses ...)
> + (if (or (eq? (service-kind svc) kind-or-name) ;kind
> + (eq? (service-type-name (service-kind svc)) kind-or-name)) ;name
As a general design pattern in Guix, “names” (symbols) are here for UI
and/or debugging purposes; they should not be used elsewhere because, by
definition, names are ambiguous. Conversely, object references are
unambiguous and non-forgeable, so I prefer interfaces that avoid “names”
entirely.
I hope that makes sense!
Ludo’.
This bug report was last modified 2 years and 15 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.