guix-devel
[Top][All Lists]
Advanced

[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: Fri, 23 Apr 2021 08:04:22 +0200

Hi,

On Fri, Apr 23 2021, Maxim Cournoyer wrote:

>> But the problem here is that it doesn’t force the user to configure the
>> field.  In a Git config for example, the user should be forced to set
>> ‘user.name’ and ‘user.email’, otherwise they can’t commit anything.  You
>> will just have to set the default value to ‘disabled’, like this:
>>
>> #+begin_src scheme
>> (define (serialize-string field-name val) ...)
>> (define-maybe string)
>> (define-configuration test-config
>>   (config
>>     (maybe-string ’disabled))
>>     "docs"")
>> #+end_src
>
> Ah, thanks for explaining, now I understand your point well.
>
> I've just tried something:
>
> --8<---------------cut here---------------start------------->8---
> (define-configuration test-config
>                        (name (string #f) "Your name"))
> scheme@(guile-user)> (test-config)
> ice-9/boot-9.scm:1669:16: In procedure raise-exception:
> ERROR:
>   1. &message: "Invalid value for field name: #f"
>   2. &configuration-error
> --8<---------------cut here---------------end--------------->8---
>
> So you could choose an invalid default value, which would force the user
> to specify it (else they'd get the not so obvious error message above).
> It should be improved too!  I'll see if I can do something.

That would be a workaround for now.  Thank you!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]