all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alex Kost <alezost@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org
Subject: Re: [SHEPHERD] [PATCH] service: Improve 'service-list'.
Date: Tue, 26 Jan 2016 12:42:30 +0300	[thread overview]
Message-ID: <87mvrswubd.fsf@gmail.com> (raw)
In-Reply-To: <8737tlfhxg.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Mon, 25 Jan 2016 22:49:47 +0100")

Ludovic Courtès (2016-01-26 00:49 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> Ludovic Courtès (2016-01-25 18:06 +0300) wrote:
>>
>>> Alex Kost <alezost@gmail.com> skribis:
>>>
>>>> From f3d21e3ec8a100a966153d03264639ebe48e8872 Mon Sep 17 00:00:00 2001
>>>> From: Alex Kost <alezost@gmail.com>
>>>> Date: Mon, 25 Jan 2016 11:18:00 +0300
>>>> Subject: [PATCH] service: Improve 'service-list'.
>>>>
>>>> * modules/shepherd/service.scm (service-list): Use
>>>>   'lookup-canonical-service' on each name instead of removing duplicates
>>>>   from the final list.
>>>
>>> [...]
>>>
>>>> diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
>>>> index f84d1dd..94f2aae 100644
>>>> --- a/modules/shepherd/service.scm
>>>> +++ b/modules/shepherd/service.scm
>>>> @@ -871,12 +871,13 @@ Return #f if service is not found."
>>>>  
>>>>  (define (service-list)
>>>>    "Return the list of services currently defined."
>>>> -  (delete-duplicates
>>>> -   (hash-fold (lambda (key services result)
>>>> -                (append services result))
>>>> -              '()
>>>> -              %services)
>>>> -   eq?))
>>>> +  (hash-fold (lambda (name services result)
>>>> +               (let ((service (lookup-canonical-service name services)))
>>>> +                 (if service
>>>> +                     (cons service result)
>>>> +                     result)))
>>>> +             '()
>>>> +             %services))
>>>
>>> OK, except that we know that SERVICE is necessarily true, because the
>>> canonical service for NAME is necessarily among SERVICES.
>>>
>>> So I would remove the ‘if’ and add a comment explaining the above.
>>>
>>> OK with this change?
>>
>> No, the service is not necessarily true.  When a service has several
>> names (e.g., "root" and "shepherd"), then %services table will contain 2
>> entries (with 'root' and 'shepherd' keys and the same (#<<service> …>)
>> value).  So for one of the hash-table entries:
>>
>>   (lookup-canonical-service 'root (list root-service))
>>
>> returns #t, and for the other:
>>
>>   (lookup-canonical-service 'shepherd (list root-service))
>>
>> it returns #f.
>
> Indeed, my bad.
>
> Then OK to push, thanks!

Pushed, thanks!

-- 
Alex

      reply	other threads:[~2016-01-26  9:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-24 15:33 [SHEPHERD] [PATCH 0/5] Replace 'dmd' service with 'root/shepherd' Alex Kost
2016-01-24 15:33 ` [PATCH 1/5] service: Rename 'services' variable to '%services' Alex Kost
2016-01-24 15:33 ` [PATCH 2/5] service: Improve style of 'for-each-service' Alex Kost
2016-01-24 15:33 ` [PATCH 3/5] service: 'service-list' returns unique services Alex Kost
2016-01-24 15:33 ` [PATCH 4/5] service: Add docstring to 'lookup-services' Alex Kost
2016-01-24 15:33 ` [PATCH 5/5] Rename 'dmd' service to 'root' Alex Kost
2016-01-25  8:55   ` Alex Kost
2016-01-24 21:20 ` [SHEPHERD] [PATCH 0/5] Replace 'dmd' service with 'root/shepherd' Ludovic Courtès
2016-01-24 21:45   ` Mathieu Lirzin
2016-01-25  8:39   ` [SHEPHERD] [PATCH] service: Improve 'service-list' Alex Kost
2016-01-25 15:06     ` Ludovic Courtès
2016-01-25 15:57       ` Alex Kost
2016-01-25 21:49         ` Ludovic Courtès
2016-01-26  9:42           ` Alex Kost [this message]

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=87mvrswubd.fsf@gmail.com \
    --to=alezost@gmail.com \
    --cc=guix-devel@gnu.org \
    --cc=ludo@gnu.org \
    /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.