guix-patches
[Top][All Lists]
Advanced

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

[bug#63985] [PATCH v3 01/11] services: configuration: Simplify normalize


From: Bruno Victal
Subject: [bug#63985] [PATCH v3 01/11] services: configuration: Simplify normalize-extra-args. (was: bug#63985: [PATCH RFC 0/5] Generic INI serializer & SRFI-171 for define-configuration)
Date: Sat, 07 Oct 2023 13:36:35 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Hi Maxim,

Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:
> Bruno Victal <mirai@makinata.eu> writes:
>>           (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?

In the (or proc …) clause the logic is still equivalent to the previous
(maybe-value proc) wrapped one. There's no problem with proc being #f as
it either means that the field is marked as `no-serialization' or it
will use the “default” serializers that appears latter within the (or …)
clause.

For sanitizers it boils down to this check further down:

--8<---------------cut here---------------start------------->8---
;; Define field validation macros.
#,@(filter-map (lambda (name pred sanitizer)
                 (if sanitizer
                     #f
                     (default-field-sanitizer name pred)))
               #'(field ...)
               #'(field-predicate ...)
               #'(field-sanitizer ...))
--8<---------------cut here---------------end--------------->8---

So if a custom sanitizer wasn't provided (which is marked internally as
#f) then this filter-map will take care of defining a default one for
it.

-- 
Thanks,
Bruno.





reply via email to

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