Subject: [netmod] YANG sub-module using definitions from the main module

From: Andy Bierman <[email-masked]>
Date: Tue, 25 Sep 2012 12:51:57 -0700

Hi,

I have a question about YANG sub-module restrictions:

4.1, para 6:

   Derived types and groupings can be defined in one module or submodule and
   used in either that location or in another module or submodule that
   imports or includes it.

7..2.2, para 3: (belongs-to prefix)

   All definitions in the local submodule and any included submodules
can be accessed
   by using the prefix.

These 2 sections do not permit a sub-module to use any top-level definitions,
(e.g., typedef, identity, grouping) from the main module, even though the
submodule is required to specify the prefix in the belongs-to-stmt.

Section 6.2.1 clearly defines the definition namespaces, so I
do not understand this restriction.  It is arbitrary and not needed.

I think this was done to prevent a parser from having to read in the
main module, and processing "main:my-type" is too hard.
I don't see how it is any harder than supporting "import foo"
and resolving "foo:my-type".

Why is this restriction in YANG?

Andy

---

From: Martin Bjorklund <[email-masked]>
Date: Tue, 25 Sep 2012 21:55:37 +0200 (CEST)

Andy Bierman <[email-masked]> wrote:
> main module

Yes.  If a submodule has access to the entire module (including all
submodules), you essentially always have to read *all* submodules when
you parse *one* submodule.  The idea was that each submodule should be
self-contained, with explicit import/include of other
modules/submodules.

/martin

---

From: Andy Bierman <[email-masked]>
Date: Tue, 25 Sep 2012 12:59:10 -0700

> self-contained, with explicit import/include of other

Maybe if this text was in the RFC it would help people understand
this subtle detail.

Andy