guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#63985] [PATCH RFC 0/5] Generic INI serializer & SRFI-171 for define


From: Maxim Cournoyer
Subject: [bug#63985] [PATCH RFC 0/5] Generic INI serializer & SRFI-171 for define-configuration
Date: Mon, 02 Oct 2023 13:00:17 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)

Hi,

Bruno Victal <mirai@makinata.eu> writes:

> * gnu/services/configuration.scm
> (define-configuration-helper, normalize-extra-args): Use #f instead of 
> %unset-value.
> ---
>  gnu/services/configuration.scm | 26 +++++++++++++-------------
>  1 file changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
> index 367b85c1be..dafe72f4fe 100644
> --- a/gnu/services/configuration.scm
> +++ b/gnu/services/configuration.scm
> @@ -190,32 +190,32 @@ (define (define-configuration-helper serialize? 
> serializer-prefix syn)
>    (define (normalize-extra-args s)
>      "Extract and normalize arguments following @var{doc}."
>      (let loop ((s s)
> -               (sanitizer* %unset-value)
> -               (serializer* %unset-value))
> +               (sanitizer* #f)
> +               (serializer* #f))
>        (syntax-case s (sanitizer serializer empty-serializer)
>          (((sanitizer proc) tail ...)
> -         (if (maybe-value-set? sanitizer*)
> -             (syntax-violation 'sanitizer "duplicate entry"
> -                               #'proc)
> +         (if sanitizer*
> +             (syntax-violation 'sanitizer
> +                               "duplicate entry" #'proc)
>               (loop #'(tail ...) #'proc serializer*)))
>          (((serializer proc) tail ...)
> -         (if (maybe-value-set? serializer*)
> -             (syntax-violation 'serializer "duplicate or conflicting entry"
> -                               #'proc)
> +         (if serializer*
> +             (syntax-violation 'serializer
> +                               "duplicate or conflicting entry" #'proc)
>               (loop #'(tail ...) sanitizer* #'proc)))
>          ((empty-serializer tail ...)
> -         (if (maybe-value-set? serializer*)
> +         (if serializer*
>               (syntax-violation 'empty-serializer
>                                 "duplicate or conflicting entry" #f)
>               (loop #'(tail ...) sanitizer* #'empty-serializer)))
>          (()  ; stop condition

The above LGTM.

>           (values (list sanitizer* serializer*)))
>          ((proc)  ; TODO: deprecated, to be removed.
> -         (null? (filter-map maybe-value-set? (list sanitizer* serializer*)))
> +         (every not (list sanitizer* serializer*))

Alternatively, using DeMorgan's law:  (not (or sanitizer* serializer*))

>           (begin
>             (warning #f (G_ "specifying serializers after documentation is \
>  deprecated, use (serializer ~a) instead~%") (syntax->datum #'proc))
> -           (values (list %unset-value #'proc)))))))
> +           (values (list #f #'proc)))))))
>  
>    (syntax-case syn ()
>      ((_ stem (field field-type+def doc extra-args ...) ...)
> @@ -239,11 +239,11 @@ (define (define-configuration-helper serialize? 
> serializer-prefix syn)
>                       default-value))
>                    #'((field-type def) ...)))
>              ((field-sanitizer ...)
> -             (map maybe-value #'(sanitizer* ...)))
> +             #'(sanitizer* ...))
>              ((field-serializer ...)
>               (map (lambda (type proc)
>                      (and serialize?
> -                         (or (maybe-value proc)
> +                         (or proc

I haven't applied it locally so may be out of context, but how do we
ensure here that sanitizer and proc aren't set to #f before calling
them?

-- 
Thanks,
Maxim





reply via email to

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