Subject: [netmod] type namespace clarification

From: Juergen Schoenwaelder <[email-masked]>
Date: Fri, 11 Dec 2009 14:24:43 +0100

Hi,

we were trying to interpret the text in section 6.2.1. and we were
not totally sure what it means. Here is an example:

  container a {
    typedef t;
  }

  container b {
    typedef t;
  }

One interpretation of 6.2.1 is that this is illegal:

      All derived type names defined within a parent node or at the
      top- level of the module or its submodules share the same type
      identifier namespace. This namespace is scoped to all descendant
      nodes of the parent node or module.  This means that any
      descendent node may use that typedef, and it MUST NOT define a
      typedef with the same name.

But then pyang does accept it. It seems the text in 6.2.1 says that
all type identifiers are in a single global namespace, only the usage
of the types is scoped. We actually are not sure what the second
sentence tries to say - and this is like why sentence three tries to
explain sentence two.

/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: Phil Shafer <[email-masked]>
Date: Fri, 11 Dec 2009 09:10:15 -0500

>      typedef with the same name.

typedefs are scoped to the parent node, so the parent in your example
is "container a" and "container b".

    container a {
        typedef t { ... }
        leaf z {
            type t;
        }
        container c {
        typedef t { ... }   // Illegal, since a's t is in scope
        leaf z { 
            type t;
        }
    }
    container b {
        typedef t { ... }  // Legal, since a's t is out of scope
        leaf z { 
            type t;
        }
    }

So the text says:

(a) they share the same space
(b) they are scoped
(c) don't allow conflicts

Scoping means the definitions move out of the namespace when they
fall out of scope.

Thanks,
 Phil

---

From: Juergen Schoenwaelder <[email-masked]>
Date: Fri, 11 Dec 2009 16:10:46 +0100

> Scoping means the definitions move out of the namespace when they

Good. One more questions - is shadowing allowed or not?

  container a {
     typedef t {}
     container b {
        typedef t {}
     }
  }

I assume the text says this second typedef is not allowed. Your (c) is
probably "shadowing is not allowed".

/js

---

From: Phil Shafer <[email-masked]>
Date: Fri, 11 Dec 2009 10:22:45 -0500

>probably "shadowing is not allowed".

Exactly.  In adding and removing from the same namespace, shadow
are errors.

Thanks,
 Phil