unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Andy Wingo <wingo@igalia.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org, John Darrington <jmd@gnu.org>
Subject: Re: [PATCH] gnu: Add Kerberos client service.
Date: Wed, 30 Nov 2016 14:52:37 +0100	[thread overview]
Message-ID: <cucmvghyt0a.fsf@igalia.com> (raw)
In-Reply-To: <874m2pktc2.fsf@gnu.org> ("Ludovic Courtès"'s message of "Wed, 30 Nov 2016 14:09:17 +0100")

On Wed 30 Nov 2016 14:09, ludo@gnu.org (Ludovic Courtès) writes:

>>  (define (validate-configuration config fields)
>>    (for-each (lambda (field)
>>                (let ((val ((configuration-field-getter field) config)))
>> -                (unless ((configuration-field-predicate field) val)
>> +                (unless (or (not val) ((configuration-field-predicate field) val))
>>                    (configuration-field-error
>>                     (configuration-field-name field) val))))
>
> Here you’re assuming that when VAL is #f, it’s necessary invalid, an
> assumption that’s questionable and wasn’t made until now.
>
> Can you instead change your own field predicate to do that?

Agreed; the usual way to do this is to define the default value as a
sentinel value that your field predicate rejects.  E.g.

  (define unset-field (list 'unset-field))

You'd make the default value be `unset-field' (by reference).  Then
assuming you defined a field of type "foo" then assuming you have an
associated predicate `foo?', you can do

  (define (predicate/not-unset pred)
    (lambda (x) (and (not (eq? x unset-field)) (pred x))))

  (define foo? (predicate/not-unset foo?))

Andy

  parent reply	other threads:[~2016-11-30 13:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-09 19:58 [PATCH] gnu: Add kerberos service John Darrington
2016-11-18 15:23 ` John Darrington
2016-11-18 22:51 ` Ludovic Courtès
2016-11-19  6:57   ` John Darrington
2016-11-21  8:59     ` Ludovic Courtès
2016-11-22 17:52       ` [PATCH] gnu: Add Kerberos client service John Darrington
2016-11-23 22:01         ` Ludovic Courtès
2016-11-29 18:39           ` John Darrington
2016-11-29 18:39             ` John Darrington
2016-11-30 13:09               ` Ludovic Courtès
2016-11-30 13:44                 ` John Darrington
2016-11-30 13:52                 ` Andy Wingo [this message]
2016-12-03 12:27                   ` John Darrington
2016-12-03 15:13                     ` Ludovic Courtès

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=cucmvghyt0a.fsf@igalia.com \
    --to=wingo@igalia.com \
    --cc=guix-devel@gnu.org \
    --cc=jmd@gnu.org \
    --cc=ludo@gnu.org \
    /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).