Subject: [YANG] 7.6, default value for a type

From: Andy Bierman <[email-masked]>
Date: Fri, 11 Jan 2008 16:27:13 -0800

Hi,

Sec 7.6, para 5 says:

    If a leaf has a "default" statement, the leaf's default value is set
    to the value of the "default" statement.  Otherwise, if the leaf's
    type has a default value, and the leaf is not mandatory, then the
    leaf's default value is set to the type's default value.  In all
    other cases, the leaf does not have a default value.

The default value for each builtin type is not defined anywhere.
This is a nice detail, and covers things like the agent creating
a bunch of counter objects or ifOperStatus objects.

It mandates that a specific value will be used, not random values.

What are the specific values?

   - int8 to uint64: 0
   - float32, float64: 0.0
   - string, binary, instance-identifier: empty string
   - enumeration:  ???  (!) [first value?]
   - boolean: false
   - bits: empty bitset
   - keyref:  default for data type of 'path'

Andy

_______________________________________________
YANG mailing list
[email-masked]
https://www1.ietf.org/mailman/listinfo/yang

---

From: Juergen Schoenwaelder <[email-masked]>
Date: Sun, 13 Jan 2008 14:43:15 +0100

>   - keyref:  default for data type of 'path'

Why not leave it undefined? It is easy to define defaults:

   typedef int8-zero {
       type int8;
       default 0;
   }

If we hard wire defaults, it will be a pain to define a type which
does not have a default, e.g. for an SNMP counter.

/js

-- 
Juergen Schoenwaelder           Jacobs University Bremen gGmbH
Phone: +49 421 200 3587         Campus Ring 1, 28759 Bremen, Germany
Fax:   +49 421 200 3103         <http://www.jacobs-university.de/>

---

From: Martin Bjorklund <[email-masked]>
Date: Sun, 13 Jan 2008 22:38:52 +0100 (CET)

> The default value for each builtin type is not defined anywhere.

This is supposed to be a feature, not a bug.  If every type has a
default, you will never be able to define optional leafs.

> a bunch of counter objects or ifOperStatus objects.

Yes.  Define ifOperStatus with a default, or use a type with a
default.

/martin

---

From: Andy Bierman <[email-masked]>
Date: Sun, 13 Jan 2008 15:28:53 -0800

> default, you will never be able to define optional leafs.

The text is misleading.
The builtin types do not have default values(good!)
The order to check the default-stmt is 1) leaf 2) typedef

Andy

---

From: Martin Bjorklund <[email-masked]>
Date: Mon, 14 Jan 2008 12:32:51 +0100 (CET)

> The order to check the default-stmt is 1) leaf 2) typedef

Ok, so it seems we all agree.  How is the text misleading?  Should it
say: 

     then the
     leaf's default value is set to the type's default value, if one
     exists.

/martin

---

From: Martin Bjorklund <[email-masked]>
Date: Mon, 14 Jan 2008 12:46:16 +0100 (CET)

>      leaf's default value is set to the type's default value, if one

I realized that this case was already covered by the current text.
Sorry for the noise.

/martin