all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Hartmut Goebel <h.goebel@crazy-compilers.com>
Cc: Guix-devel <guix-devel@gnu.org>
Subject: Re: Question regarding record types
Date: Sun, 06 Nov 2016 18:24:31 +0100	[thread overview]
Message-ID: <87r36o1pyo.fsf@gnu.org> (raw)
In-Reply-To: <a33db22e-d2da-d13b-670a-55df31b07699@crazy-compilers.com> (Hartmut Goebel's message of "Fri, 4 Nov 2016 23:31:42 +0100")

Hi!

Hartmut Goebel <h.goebel@crazy-compilers.com> skribis:

> in the services modules, there are configuration types defined like this:
>
> (define-record-type* <nginx-configuration>
>   nginx-configuration make-nginx-configuration
>   nginx-configuration?
>   (nginx         nginx-configuration-nginx)         ;<package>
>   (log-directory nginx-configuration-log-directory) ;string
>   (run-directory nginx-configuration-run-directory) ;string
>   (vhosts        nginx-configuration-vhosts
>                  (default '()))   ;list of <nginx-vhost-configuration>
>   (file          nginx-configuration-file))         ;string | file-like
>
> I wonder if it's really necessary to have this prefix
> "nginx-configuration-" for what I assume is the getter? For me it looks
> redundant. The getter is only valid for this very type, so why should
> there be any need to add a prefix?

A widespread Scheme convention is that, for a type T, the procedure to
access field F is called ‘T-G’.  So, ‘nginx-configuration-log-directory’
accesses the ‘log-directory’ field of an ‘nginx-configuration’ record.

Calling it simply ‘log-directory’ would be ambiguous and more likely to
lead to name clashes (Guile’s module system provides tools to
select/rename imported bindings, but still.)

In practice, what typically happens in the case of configuration records
is that (1) we use ‘match’ within the module, so we don’t have to use
the long names, and (2) we rarely have to use the long accessor names
outside.

Ludo’.

      reply	other threads:[~2016-11-06 17:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-04 22:31 Question regarding record types Hartmut Goebel
2016-11-06 17:24 ` Ludovic Courtès [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=87r36o1pyo.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guix-devel@gnu.org \
    --cc=h.goebel@crazy-compilers.com \
    /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.