Subject: [netmod] defaults and ranges

From: Andy Bierman <[email-masked]>
Date: Thu, 11 Jun 2009 16:01:17 -0700

Hi,

Just reading sec. 9.2.4 again, to be sure,
and the draft says it is OK to restrict the
range further.

    typedef A {
       type uint32;
       default 42;
    }

    typedef B {
      type A {
         range "14 .. max";
      }
    }

    typedef C {
      type B {
         range "min .. 41";
      }
    }

    leaf busted { type C; }

Type B is OK because the default 42 is still valid.
What about type C?  The range there is 14 .. 41,
and the default of 32 is no longer valid.

I just check my code and it does the wrong thing
in both places:

   1) fails to detect that typedef C is invalid
   2) attempts to assign a default of 42 to leaf busted

So what is the right answer?
IMO, typedef C is invalid YANG.

Andy

---

From: Martin Bjorklund <[email-masked]>
Date: Fri, 12 Jun 2009 08:18:59 +0200 (CEST)

> and the default of 32 is no longer valid.

[...]

> IMO, typedef C is invalid YANG.

Section 7.3.4 says:

  If the base type has a default value, and the new derived type does
  not specify a new default value, the base type's default value is
  also the default value of the new derived type.  If the base type's
  default value is not valid according to the new restrictions, the
  derived type MUST define a new default value.

So this C is not legal.

/martin

---

From: WashamFan <[email-masked]>
Date: Fri, 12 Jun 2009 17:30:56 +0800

Hi,

----- Original Message -----
From: Andy Bierman <[email-masked]>
Date: Friday, June 12, 2009 7:01 am
Subject: [netmod] defaults and ranges
To: NETMOD Working Group <[email-masked]>

>  IMO, typedef C is invalid YANG.

IMO. if typedef C is equivalent to semantically

    typedef C {
        type uint32;
        range "14..41";
        default 42;
    }

then C in invalid.

washam