Re: [netmod] false() vs 'false' in 'when' statements

"Sterne, Jason (Nokia - CA/Ottawa)" <jason.sterne@nokia.com> Wed, 08 August 2018 13:36 UTC

Return-Path: <jason.sterne@nokia.com>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 7AE361277C8 for <netmod@ietfa.amsl.com>; Wed, 8 Aug 2018 06:36:50 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.911
X-Spam-Level:
X-Spam-Status: No, score=-1.911 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, T_DKIMWL_WL_HIGH=-0.01] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=nokia.onmicrosoft.com
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id njX-81gMPFc4 for <netmod@ietfa.amsl.com>; Wed, 8 Aug 2018 06:36:47 -0700 (PDT)
Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30101.outbound.protection.outlook.com [40.107.3.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 469CD1252B7 for <netmod@ietf.org>; Wed, 8 Aug 2018 06:36:47 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.onmicrosoft.com; s=selector1-nokia-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cHuEeZfZwQEAsg7vJTUEhVx5fCwKIcYyLOMMZFAqmt8=; b=UE22eCbEYBO5OfUiYsUOxS8XDPt3/m1ylHwSTSmCPDB8pODv6GtmImHAFBUaED9U5liyVEbFDOFEfUHbb5u5tFMI3XySjPXSjvwEuufsupNsdATZWX/qHs3bnT6lf8wAaSK0uPovQdkiwf0HyALgM4mEh5QcvK9GDwhpogvCnyg=
Received: from VI1PR07MB3981.eurprd07.prod.outlook.com (52.134.28.141) by VI1PR07MB4368.eurprd07.prod.outlook.com (20.176.7.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.17; Wed, 8 Aug 2018 13:36:45 +0000
Received: from VI1PR07MB3981.eurprd07.prod.outlook.com ([fe80::dd01:b567:f507:8f07]) by VI1PR07MB3981.eurprd07.prod.outlook.com ([fe80::dd01:b567:f507:8f07%4]) with mapi id 15.20.1038.013; Wed, 8 Aug 2018 13:36:45 +0000
From: "Sterne, Jason (Nokia - CA/Ottawa)" <jason.sterne@nokia.com>
To: "Ivory, William" <william.ivory@intl.att.com>, "netmod@ietf.org" <netmod@ietf.org>
Thread-Topic: [netmod] false() vs 'false' in 'when' statements
Thread-Index: AdQudRPPuaY7IZR/R5mIg6eZugDJwAApuzeA
Date: Wed, 08 Aug 2018 13:36:45 +0000
Message-ID: <VI1PR07MB39813DB16C1AF2314EBD14EE9B260@VI1PR07MB3981.eurprd07.prod.outlook.com>
References: <VI1PR07MB3981A0DC1F7069AFC5BE72AD9B270@VI1PR07MB3981.eurprd07.prod.outlook.com> <E3378E0605547F4E854DEE0CB1116AB03A8BA8@gbcdcmbx03.intl.att.com>
In-Reply-To: <E3378E0605547F4E854DEE0CB1116AB03A8BA8@gbcdcmbx03.intl.att.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-originating-ip: [135.245.20.4]
x-ms-publictraffictype: Email
x-microsoft-exchange-diagnostics: 1; VI1PR07MB4368; 6:6mq/ViNFOOYc6mIMuEgbpO4jzbCDMSX6STRGYP81JIF8TagckyREUZUhI589BJOO7DpYBjq/Uwl9PclMUoq03G7Tx/aZ8ROSjYiETZw7qwYtgvtApED8dU3rklVdHPNm6pDAyFNT0u4tvniSwbW6fysaiivyi4sev7cxN8phmK/ogGTh8GL2EpB9OYMCTV7Ov4Ng6PLhkiQNCOocCgLqg+gPPJyRToBYM3CG72yzZGhKSQ8q9nKI0xn9YVvpe0yc2ycsiSuicRs7o0TU9ZgPvB1utUdbxZQVzIp61H+hil4flSArtNEnDkLt8la/XTOli/EVF5gJI9ZR9zbtcUJ+CI5lWUQGUk8/C4DqiXC7+w2n7quOnJas94mf1CONibtiTULrH6QxwrMfaxG5/s8cGkuC5vwujJtc9z9BFEhedwbiv0SKwn6xnM5WtN+fTbhbTOSFtajg5TGwdNH/UnbnTw==; 5:ovQ9QXXTimugOi8uJ9FK8V88wkh3Zg9zYrt+X6mCQFhXmYqVKIyA2B2mPaEQDskj9wLFFWrdXG08397nzd6weh6Ez2aTW6IAmbz1Th5qI06bJ3JHfScL2KAuBUg31QQCFZyAaMMtAEuhTN7HMMGWrJoNKBnNgvwpgSk6GeF+LT4=; 7:lA1FU8zFZeTcIYb0vdC6DYAFL3jzGS/emJ5d5npM3Bv2nh0FJD3F8vZzv9tcD9BsOrqe7VYyRSJI/AMX+bucXTKN9R7Wfi1LsH/meql78UD9l1qq4rU+Q4HNLq5Al9JmYdGXpCzY4bqGVNxcskJmPoRbpCgModzAL7ZqnIPqIogTxjeeyc61laow5kMEQlj8Wj3fsP+xpO5VfxbqYxoyPjmvR6t4EC8/BE0c8VkYwo7qpziPqGlLo/IRf13vKl8i
x-ms-exchange-antispam-srfa-diagnostics: SOS;
x-ms-office365-filtering-correlation-id: 5c083af0-b9d0-4f74-d48b-08d5fd33fbbb
x-ms-office365-filtering-ht: Tenant
x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7193020); SRVR:VI1PR07MB4368;
x-ms-traffictypediagnostic: VI1PR07MB4368:
x-microsoft-antispam-prvs: <VI1PR07MB43682F8BAE2EBE6EAE32D1989B260@VI1PR07MB4368.eurprd07.prod.outlook.com>
x-exchange-antispam-report-test: UriScan:(82608151540597)(97927398514766)(195916259791689)(788757137089)(109105607167333);
x-ms-exchange-senderadcheck: 1
x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3002001)(3231311)(11241501184)(806099)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:VI1PR07MB4368; BCL:0; PCL:0; RULEID:; SRVR:VI1PR07MB4368;
x-forefront-prvs: 07584EDBCD
x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(376002)(396003)(39860400002)(136003)(366004)(13464003)(53754006)(199004)(189003)(74316002)(229853002)(305945005)(8676002)(7736002)(966005)(99286004)(478600001)(486006)(81166006)(81156014)(8936002)(7696005)(14454004)(76176011)(476003)(106356001)(3846002)(33656002)(105586002)(6116002)(110136005)(6436002)(316002)(2906002)(68736007)(53936002)(9686003)(5660300001)(6246003)(5250100002)(66066001)(2501003)(256004)(25786009)(446003)(53546011)(55016002)(102836004)(2900100001)(6506007)(11346002)(186003)(86362001)(6306002)(26005)(97736004)(6346003); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR07MB4368; H:VI1PR07MB3981.eurprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1;
received-spf: None (protection.outlook.com: nokia.com does not designate permitted sender hosts)
authentication-results: spf=none (sender IP is ) smtp.mailfrom=jason.sterne@nokia.com;
x-microsoft-antispam-message-info: egFOLVtVbApU9k4bh0tFvKIymDG0r4rP0nICpiZ3gRa5MF5E/e7FERokM/NJnFRomeY4y75ltPmuB3br7WWKk6XvVbacbZ9RvsPBkZTq5D+m9Wuq2c26rpMkAjXWBhiqdVMSge2krFMlRB+4Li16ffW7spDtHsBI2/H/BXBDBsEagsnaeoOCTeqE1SLFxKxAlzIvJT21JlpvjQ7vH+ox9ezK9dPJX3g1RKBQYlsKLaRBDnKaitgGINYXgqOwDz1yCAL5CTF1XMwewxcYmEEZLOYyocDmdCPJqd6pFJqJA8vIHiQuRaVoSox4PHgdLu3KB1Fm9vK4NeNfYRPQSVAKuHMfftCfRmDTaXw/5SrLQ4d2JYJ4H/VvwN/5CgnQr+SHCB9haHZV7W6WOlvg81ETcw==
spamdiagnosticoutput: 1:99
spamdiagnosticmetadata: NSPM
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: nokia.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 5c083af0-b9d0-4f74-d48b-08d5fd33fbbb
X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Aug 2018 13:36:45.0983 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 5d471751-9675-428d-917b-70f44f9630b0
X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB4368
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/InXSHaaWlT41e6RgSMXu4yvAJUY>
Subject: Re: [netmod] false() vs 'false' in 'when' statements
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.27
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 08 Aug 2018 13:36:51 -0000

Thanks William.
Please see below.
Regards,
Jason

> -----Original Message-----
> From: Ivory, William <william.ivory@intl.att.com>
> Sent: Wednesday, August 8, 2018 3:27 AM
> To: Sterne, Jason (Nokia - CA/Ottawa) <jason.sterne@nokia.com>;
> netmod@ietf.org
> Subject: Re: [netmod] false() vs 'false' in 'when' statements
> 
> On 07/08/18 18:37, Sterne, Jason (Nokia - CA/Ottawa) wrote:
> Hi all,
> 
> When comparing the value of a boolean leaf in a 'when' statement (or a 'must'
> statement), is an equality comparison to 'true' or 'false' the same as a check
> against true() or false() ?
> 
> For example:
> 
> leaf a {
>     type boolean;
> }
> leaf b {
>     type uint32;
>     when ".../a = 'true'";
> }
> leaf c {
>     type uint32;
>     when ".../a = 'false'";
> }
> (note that neither b nor c can be configured if leaf a isn't explicitly configured
> with a value since there is no default)
> 
> If I replace the two 'when' statements above with the following instead, is the
> behavior the same ?
>     ...
>     when ".../a = true()";
>     ...
>     when ".../a = false()";
>     ...
> 
> Or does "../a = true()" behave as an existence check on leaf a and would be
> enabled whether a is configured as true or false ?
> 
> Regards,
> Jason
> 
> 
> 
> See https://www.w3.org/TR/1999/REC-xpath-19991116/#booleans
> 
> (a) "../a = 'true'"
> 
> Compares 'string-value' (same as value of node if a leaf, rather more
> interesting if a list / container!) of each node in nodeset generated by '../a' and
> if any node in the nodeset matches 'true', expression is true.

[>>JTS: ] In my specific example, leaf a is a single Boolean leaf.  In that case, are these equivalent ?
    when ".../a = 'true'";
    when ".../a = true()";
and are these also equivalent ?
    when ".../a = 'false'";
    when ".../a = false()";
(sorry if I'm being dense here, but I'm not 100% positive if I'm interpreting your explanations correctly and getting the right conclusion.  I've never seen must or when statements that use = false() or = true()).

[>>JTS: ] Are the strings 'true' and 'false' the "string-value" (that you mention above) for a Boolean leaf ?
'a' is a single Boolean leaf so the nodeset is that single leaf and the value is 'true' or 'false'.

> 
> (b) "../a = true()"
> 
> Similar to above but after getting the string-value, this is converted to a
> boolean before comparing with the boolean true.

[>>JTS: ] I'm a bit confused here.  Are you saying that the string-value of leaf a is converted to a Boolean ?
Do the string-values of a convert to something that is equal to true() or false() ?

> 
> (c) '../a'
> 
> True if the nodeset generated by this expression is not empty.
> 
> ---
> 
> Caveats alluded to above are that if '../a' matches multiple nodes, then only
> one of these nodes needs to pass the test for the test to be true.  Separately, if
> any of the nodes are not leaves, the 'string-value' is a concatenated string of
> the values of the node's child / grandchild leaves.
> 
> Hope that helps.  You wouldn't believe the number of unit tests I have to make
> sure we get this logic right!  Using '!=' when comparing a nodeset with >1 node
> with other values is very likely not to give the answer you expect (-:
> 
> Regards,
> 
> William
>