all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Chris Marusich <cmmarusich@gmail.com>
Cc: guix-devel@gnu.org
Subject: Re: isc-bind service draft
Date: Thu, 16 Nov 2017 17:18:00 +0100	[thread overview]
Message-ID: <87fu9eci4n.fsf@gnu.org> (raw)
In-Reply-To: <87tvxuewmq.fsf@gmail.com> (Chris Marusich's message of "Wed, 15 Nov 2017 19:21:49 -0800")

Chris Marusich <cmmarusich@gmail.com> skribis:

> Chris Marusich <cmmarusich@gmail.com> writes:
>
>>>
>>> (define (emit-bind-options-config options)
>>>   (match options
>>>     (($ <bind-options-configuration> user _ run-directory pid-file
>>>                                      listen-v4 listen-v6 listen-port
>>>                                      allow-recursion? allow-transfer?
>>>                                      allow-update?
>>>                                      version hostname server-id)
>>
>> Some of these slots (e.g., listen-v4) appear to be un-used.  Instead of
>> listing positional slots by name, maybe it would be better to bind the
>> entire <bind-options-configuration> to a variable, and then use the
>> accessor procedures (e.g., bind-options-configuration-listen-v4) to get
>> just the attributes you need.  This has the benefit of being more
>> resilient to refactorings which change the order of fields in the
>> record, also.  I realize that a lot of the code in Guix relies on
>> positional matching of slots like this, so I don't mind if you keep it
>> as-is, but consider my suggestion as food for thought.
>
> FYI, I just learned that there is a way to do this with pattern matching
> in Guile.  You can write something like the following:
>
> (match options
>   ((? bind-options-configuration? (= bind-options-configuration-listen-v4 listen-v4))
>    ;; Do something with listen-v4
>    (foo listen-v4)))
>
> As far as I know, this is the same as writing something like:
>
> (match options
>   ((? bind-options-configuration? opts)
>    (let ((listen-v4 (bind-options-configuration-listen-v4 opts)))
>      ;; Do something with listen-v4
>      (foo listen-v4))))

In this particular case I would argue that the second version is more
readable.

Ludo’.

  reply	other threads:[~2017-11-16 16:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-09 20:11 isc-bind service draft Oleg Pykhalov
2017-11-15  4:48 ` Chris Marusich
2017-11-16  3:21   ` Chris Marusich
2017-11-16 16:18     ` Ludovic Courtès [this message]
2017-11-24  8:31       ` Oleg Pykhalov
2017-11-30 17:03         ` Ludovic Courtès
2017-11-16 16:19 ` 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=87fu9eci4n.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=cmmarusich@gmail.com \
    --cc=guix-devel@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.