Subject: [netmod] Choice corer cases 2

From: Balazs Lengyel <[email-masked]>
Date: Tue, 6 Oct 2015 11:24:11 +0200

Hello,
Some more corner cases for embedded choices, with my solutions in them. 
How an average operator or even model implementer would figure these out 
is anyone's guess. regards Balazs

            choice scen9 {
                case A {
                    choice subChoiceA {
                        mandatory true;        // this mandatory has 
absolutely no effect as the case A above might not exist
                        case A {
                            leaf scen12-num1 { type uint8; default 1; 
}       // this default has absolutely no effect
                                     // if the leaf exists it has a 
value if you delete it the whole choice scen9 becomes empty
                        }
                        case B {
                            leaf scen12-num2 { type uint8; }
                        }
                    }
                }
                case B {
                    leaf scen12-num1 { type uint8; }
                }
            }

-- 
Balazs Lengyel                       Ericsson Hungary Ltd.
Senior Specialist
ECN: 831 7320
Mobile: +36-70-330-7909              email: [email-masked]

---

From: Balazs Lengyel <[email-masked]>
Date: Tue, 6 Oct 2015 11:27:05 +0200

Having statements default/mandatory in the model that seem to mean 
something, but practically have no effect is most confusing.
Balazsd

On 2015-10-06 11:24, Balazs Lengyel wrote:
> Hello,
> Some more corner cases for embedded choices, with my solutions in 
> them. How an average operator or even model implementer would figure 
> these out is anyone's guess. regards Balazs
>
>            choice scen9 {
>                case A {
>                    choice subChoiceA {

---

From: Ladislav Lhotka <[email-masked]>
Date: Tue, 6 Oct 2015 11:34:54 +0200

> On 06 Oct 2015, at 11:27, Balazs Lengyel <[email-masked]> wrote:
> 
> Having statements default/mandatory in the model that seem to mean something, but practically have no effect is most confusing.

They do have an effect but only in some contexts:

- default on a leaf(-list) inside a case applies when the case is designated as default,

- mandatory applies if some nodes from that case exist.

The latter condition requires that no two cases contain data nodes of the same name - in your example, if "scen12-num1" is present, it is impossible to determine whether it comes from case A/A or B. So this should be an error.

Lada

>> Some more corner cases for embedded choices, with my solutions in them. How an average operator or even model implementer would figure these out is anyone's guess. regards Balazs
>> 
>>           choice scen9 {
>>               case A {
>>                   choice subChoiceA {
>>                       mandatory true;        // this mandatory has absolutely no effect as the case A above might not exist
>>                       case A {
>>                           leaf scen12-num1 { type uint8; default 1; }       // this default has absolutely no effect
>>                                    // if the leaf exists it has a value if you delete it the whole choice scen9 becomes empty
>>                       }
>>                       case B {
> _______________________________________________
> netmod mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/netmod

--
Ladislav Lhotka, CZ.NIC Labs
PGP Key ID: E74E8C0C

---

From: Martin Bjorklund <[email-masked]>
Date: Tue, 06 Oct 2015 12:05:11 +0200 (CEST)

Balazs Lengyel <[email-masked]> wrote:
>                        mandatory true; // this mandatory has absolutely no
>                        effect as the case A above might not exist
>                        case A {
>                                     // if the leaf exists it has a value if
>                                     you delete it the whole choice scen9
>                                     becomes empty
>                        }
>                        case B {

Note that this is similar to a simple choice:

  choice x {
    case a {
      leaf foo {
        type int32;
        default 42;
      }
    }
  }

/martin