From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Wingo Subject: Re: [PATCH] gnu: Add Kerberos client service. Date: Wed, 30 Nov 2016 14:52:37 +0100 Message-ID: References: <87shqh500f.fsf@gnu.org> <1480444784-32432-1-git-send-email-jmd@gnu.org> <1480444784-32432-2-git-send-email-jmd@gnu.org> <874m2pktc2.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37232) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cC5KC-0007Q7-C5 for guix-devel@gnu.org; Wed, 30 Nov 2016 08:53:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cC5K9-0003c4-86 for guix-devel@gnu.org; Wed, 30 Nov 2016 08:53:28 -0500 In-Reply-To: <874m2pktc2.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Wed, 30 Nov 2016 14:09:17 +0100") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: guix-devel@gnu.org, John Darrington On Wed 30 Nov 2016 14:09, ludo@gnu.org (Ludovic Court=C3=A8s) 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 f= ield) val)) >> (configuration-field-error >> (configuration-field-name field) val)))) > > Here you=E2=80=99re assuming that when VAL is #f, it=E2=80=99s necessary = invalid, an > assumption that=E2=80=99s questionable and wasn=E2=80=99t 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