unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: raingloom <raingloom@riseup.net>
To: Xinglu Chen <public@yoctocell.xyz>
Cc: guix-devel@gnu.org, Maxim Cournoyer <maxim.cournoyer@gmail.com>
Subject: Re: Best practices for writing services
Date: Mon, 26 Apr 2021 22:29:01 +0200	[thread overview]
Message-ID: <20210426222901.52e46664@riseup.net> (raw)
In-Reply-To: <871rb27plv.fsf@yoctocell.xyz>

On Thu, 22 Apr 2021 09:19:56 +0200
Xinglu Chen <public@yoctocell.xyz> wrote:

> On Thu, Apr 22 2021, raingloom wrote:
> 
> >> One thing that I find a little annoying is that you have to
> >> specify a default value for the fields.  
> >
> > Are you sure? If you don't specify a default, won't the user just be
> > forced to write
> > (service whatever
> > 	(whatever-configuration
> > 		(mandatory-field 'bleepbloop)))
> >
> > instead of the shorter (service whatever)?  
> 
> If I write something like this
> 
> #+begin_src scheme
> (use-modules (gnu services configuration))
> (define (serialize-list field-name val) "")
> (define-configuration test-config
>   (config
>    (list)
>    "configuration for test"))
> #+end_src
> 
> and evaluate it, I will get an error.  I have to specify a default
> value for the ‘config’ field to make it work.
> 
> #+begin_src scheme
> (use-modules (gnu services configuration))
> (define (serialize-list field-name val) "")
> (define-configuration test-config
>   (config
>    (list '())                           ;default to '()
>    "configuration for test"))
> #+end_src
> 

Weird. I'd consider this a bug in define-configuration.
define-record-type* does not have this limitation.


      reply	other threads:[~2021-04-26 20:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-18 15:23 Best practices for writing services Xinglu Chen
2021-03-19 16:12 ` Joshua Branson
2021-03-19 17:01   ` Xinglu Chen
2021-04-21  3:54 ` Maxim Cournoyer
2021-04-21 10:45   ` Xinglu Chen
2021-04-21 18:05     ` Maxim Cournoyer
2021-04-22  7:27       ` Xinglu Chen
2021-04-23  4:42         ` Maxim Cournoyer
2021-04-23  6:04           ` Xinglu Chen
2021-04-21 22:10     ` raingloom
2021-04-22  7:19       ` Xinglu Chen
2021-04-26 20:29         ` raingloom [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

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210426222901.52e46664@riseup.net \
    --to=raingloom@riseup.net \
    --cc=guix-devel@gnu.org \
    --cc=maxim.cournoyer@gmail.com \
    --cc=public@yoctocell.xyz \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).