[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Best practices for writing services
From: |
Xinglu Chen |
Subject: |
Re: Best practices for writing services |
Date: |
Thu, 22 Apr 2021 09:19:56 +0200 |
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