Re: [yang-doctors] guideline for enum and value?

Andy Bierman <andy@yumaworks.com> Wed, 14 February 2018 17:35 UTC

Return-Path: <andy@yumaworks.com>
X-Original-To: yang-doctors@ietfa.amsl.com
Delivered-To: yang-doctors@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 408FE12D777 for <yang-doctors@ietfa.amsl.com>; Wed, 14 Feb 2018 09:35:37 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.6
X-Spam-Level:
X-Spam-Status: No, score=-2.6 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=yumaworks-com.20150623.gappssmtp.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 ND4ZuoFviEkO for <yang-doctors@ietfa.amsl.com>; Wed, 14 Feb 2018 09:35:34 -0800 (PST)
Received: from mail-lf0-x229.google.com (mail-lf0-x229.google.com [IPv6:2a00:1450:4010:c07::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id D1666126D85 for <yang-doctors@ietf.org>; Wed, 14 Feb 2018 09:35:33 -0800 (PST)
Received: by mail-lf0-x229.google.com with SMTP id c188so14634216lfc.11 for <yang-doctors@ietf.org>; Wed, 14 Feb 2018 09:35:33 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yumaworks-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=tTSEOihlSENvCjsKYKoKeI2J2CZFy2lIBhafBM7qu2M=; b=MfwkkTg3pRh7b+R2YHJ/KhuEI5hH02EhCj8xorTFoNW7PEwTg3aPCpSP/7BEzpK2mS Ve7lbGUvfLBKqwrSf3p74gtz8onyJH8qRrka/gENk/DPgSPwqs+eemltN10SqxNZh5Ru kiey68imVRMzXkoiIdan55DIIciCyEOu0KJ0KiZ5WPF8cqa8QdjnWB2/5EZ8/fjAVoMs ErFN7yYUxbP/0VsNHYVGE/N7CboyxVQxMgKpv+8tuwQT7Msg32PG50frlLU3DWTYC6l3 G02IVT5D393md6b5X9Q/KywaIAEQsBLz5BZm9X5oU9fI5rqG1R0EkXEBPK4xffjObLWJ IM5w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=tTSEOihlSENvCjsKYKoKeI2J2CZFy2lIBhafBM7qu2M=; b=ljcaF1nI4t/LwidwYRxJK99Zh+EZweAZxKVjlfoOiPj3Z8HU1NCkeAPlQgIVqH2h+l iFvengmnUZN2oi42RmZPlkZm37uqBJePApkbq4Eg6LF+vghdHXANIXKRYYNl3XWMOlDl BWGJigniuFOHTStSbyRnwhqoz5AaCFwwoe2VJx3hib2RtEKpDrQtsjAgCrtXuMS/QKqH n/tl8rHRQDUcRWUjVxspts/LkL15FJdUtGyQmOVjo1F5jdi1nZWNUbA6J6Qm7H3Gcw19 N979jJP0fKKpN1zsDiq4NwaAV6i2SQYAE+HUPbyB+Tvza68LJ99ZDAuB1lHj8KR78f2A xitg==
X-Gm-Message-State: APf1xPBUenpYtPbPs+UO7OGUfXF/Z2NWkwwfumFvpbzhN7mxVi31q6tV 2iPbn57PnUToUViQo0Dt88NNZZIov7jK8BhEQI+PEg==
X-Google-Smtp-Source: AH8x227XYoaWf1n5U1uuwWmYdcOIsOuKP0pjlBNowVl5WtUh8pcMnbd9+unqaAMsYqaztCfnDGCimhOKuQA0exuCpXo=
X-Received: by 10.46.44.21 with SMTP id s21mr4035544ljs.117.1518629731927; Wed, 14 Feb 2018 09:35:31 -0800 (PST)
MIME-Version: 1.0
Received: by 10.25.21.210 with HTTP; Wed, 14 Feb 2018 09:35:31 -0800 (PST)
In-Reply-To: <20180214165213.gu6dngw5c75j2sfh@elstar.local>
References: <20180125.095921.224499312159563778.mbj@tail-f.com> <20180125091118.tjn5eiv2hzmc7k23@elstar.local> <dfb94426-c408-e215-e23b-539e127050a2@cisco.com> <20180125.120804.68412726225731762.mbj@tail-f.com> <0db2c4d1-ac4d-dcc6-b2b9-c580427a6a84@cisco.com> <20180214154740.l375k2kmodgvzvdx@elstar.local> <20180214155951.eqaskkjs67bt6zjc@elstar.local> <748E69BA-6AF6-405D-BAEC-CBB3DF58F70D@cisco.com> <20180214165213.gu6dngw5c75j2sfh@elstar.local>
From: Andy Bierman <andy@yumaworks.com>
Date: Wed, 14 Feb 2018 09:35:31 -0800
Message-ID: <CABCOCHSAH4zpGZS=oYaPPvRXiSWMbEpGf3QCLDNBxzb1GYE0VA@mail.gmail.com>
To: Juergen Schoenwaelder <j.schoenwaelder@jacobs-university.de>, "Einar Nilsen-Nygaard (einarnn)" <einarnn@cisco.com>, "Benoit Claise (bclaise)" <bclaise@cisco.com>, Martin Bjorklund <mbj@tail-f.com>, "yang-doctors@ietf.org" <yang-doctors@ietf.org>
Content-Type: multipart/alternative; boundary="f4f5e8079fc4b7a29705652f89a8"
Archived-At: <https://mailarchive.ietf.org/arch/msg/yang-doctors/-4ZJWLHVJeRdwSaxk3kznTLELuc>
Subject: Re: [yang-doctors] guideline for enum and value?
X-BeenThere: yang-doctors@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: Email list of the yang-doctors directorate <yang-doctors.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/yang-doctors>, <mailto:yang-doctors-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/yang-doctors/>
List-Post: <mailto:yang-doctors@ietf.org>
List-Help: <mailto:yang-doctors-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/yang-doctors>, <mailto:yang-doctors-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 14 Feb 2018 17:35:37 -0000

On Wed, Feb 14, 2018 at 8:52 AM, Juergen Schoenwaelder <
j.schoenwaelder@jacobs-university.de> wrote:

> Once again, see the CBOR encoding work where they do make use of the
> enum value on the wire (draft-ietf-core-yang-cbor-05 section 5.6).
>
>
The CBOR encoding is extremely fragile and does not work if the enum is in
a union type.

I think this YANG guideline is from the 1st RFC.

The enum and bit values in YANG are rather misleading since they do not
appear
in any protocol operations.

They add no value at all if the type has no use for them.
SMIv2 is full of busy work the authors must complete.
Looks like you want YANG to be the same way.



> /js
>


Andy


>
> On Wed, Feb 14, 2018 at 04:19:58PM +0000, Einar Nilsen-Nygaard (einarnn)
> wrote:
> > For me it's about who the values of the enums are for, and the impact on
> model evolution in different places. The enum values are explicitly
> intended as for model implementers to use, and have no real meaning to
> model consumers as the canonical representation is the string identifier.
> However, once a value is assigned via a "value", that value may never
> change. I have seen developers naively assign explicit values from other
> sources (e.g. system header files on the OS) and then inadvertently see
> problems when they implement the model on top of a new OS, where the value
> matching the symbol is not the same, and so the developers just (illegally)
> changed the value in the value clause. This still has zero impact on the
> end consumer of the model, as they deal with the string, but is a backwards
> compatibility violation that need not have happened.
> >
> > In general, I think embedding values that are primarily targeted to
> implementers of a model in what is also the external format is just not all
> that helpful.
> >
> > Not a huge deal, but reduces coupling, reduces opportunity for
> inadvertent backwards-compatibility breakage, and encourages better
> implementation code/model hygiene as all parties will be encouraged to
> utilize symbols rather than flawed values. I would like to see both
> consumers and implementers of models get to the point where:
> >
> > type enumeration { enum foo; enum bar; }
> >
> > and
> >
> > type enumeration { enum bar; enum foo; }
> >
> > ...are ultimately treated the same and such that reordering of symbols
> doesn't break things. I've seen enough broken code based on order-dependent
> integer value assignments combined with people using the values instead of
> symbols to last several lifetimes, and anything we can do to remove
> opportunities for mistakes seems like a good thing.
> >
> > Cheers,
> >
> > Einar
> >
> > On Feb 14, 2018, at 3:59 PM, Juergen Schoenwaelder <
> j.schoenwaelder@jacobs-university.de<mailto:j.schoenwaelder@jacobs-
> university.de>> wrote:
> >
> > On Wed, Feb 14, 2018 at 04:47:40PM +0100, Juergen Schoenwaelder wrote:
> >
> > And:
> >
> >  Do not use explicit 'value' statements, except if:
> >     o the enum corresponds to some standard integer value, or
> >     o you update the set of enums by inserting new enums in the middle of
> > the list
> >
> > I am not sure why we would recommend this.
> >
> >
> > More specifically, I do not see why
> >
> >  type enumeration { enum foo { value 0; }; enum bar { value 1; }; }
> >
> > is to be avoided in favor of
> >
> >  type enumeration { enum foo; enum bar; }
> >
> > given that they mean the same and the first one is explicit and robust
> > to changes while the second one must be handled with care (only append
> > enums, never reorder enums). Yes, clueful YANG authors can handle the
> > later fine as they will understand that if order changes are needed,
> > you have to move to explicit value assignments. My fear is that not
> > all YANG authors will be aware of this (but then many of those authors
> > likely also do not read guidelines).
> >
> > /js
> >
> > --
> > Juergen Schoenwaelder           Jacobs University Bremen gGmbH
> > Phone: +49 421 200 3587         Campus Ring 1 | 28759 Bremen | Germany
> > Fax:   +49 421 200 3103         <https://www.jacobs-university.de/>
> >
>
> --
> Juergen Schoenwaelder           Jacobs University Bremen gGmbH
> Phone: +49 421 200 3587         Campus Ring 1 | 28759 Bremen | Germany
> Fax:   +49 421 200 3103         <https://www.jacobs-university.de/>
>
> _______________________________________________
> yang-doctors mailing list
> yang-doctors@ietf.org
> https://www.ietf.org/mailman/listinfo/yang-doctors
>