netmod-wg / yang-next

Feature requests for future versions of YANG
6 stars 0 forks source link

Consider relaxing identity uniqueness to only require uniqueness with the base identity hierarchy #91

Open rgwilton opened 5 years ago

rgwilton commented 5 years ago

Flagging this only because it came up as a discussion point on yang-doctors.

Currently identities must be unique within a module.

So, in the case of loopback, this meant that I originally defined "loopback-internal", "loopback-line", "loopback-connector" as descendants of base identity "loopback" to avoid namespace collisions. This was seen as being verbose, and that it would be better if the identities were "internal", "line" and "external", but has a greater risk of a namespace collision with other future identities in the same YANG module (not very likely in this particular case, but more plausible in other scenarios).

An alternative approach would be to only require identities to be unique within descendants of the base identity.

E.g. allow a YANG module to have:

 identity loopback {
  }
  identity internal {
    base loopback;
  }
  identity line {
    base loopback;
  }

identity another-base {
  }
  identity internal {
    base  another-base;
  }
  identity external {
    base  another-base;
  }

All existing YANG modules would be backwards compatible to this approach. But would require churn in implementations to be able to support it, but what might be a fairly corner case condition.

abierman commented 2 weeks ago

This is not backward compatible. The internal and external strings are duplicates and not allowed. It is very confusing having identity names that are different codepoints.

This is not even required. Following syntax is allowed

Note that base is an OR expression in the identity but an AND expression in the identityref

 identity loopback {
  }
  identity internal {
    base loopback;
    base another-base;
  }
  identity line {
    base loopback;
    base another-base;
  }

  identity another-base {
  }

Close: complexity: low, bc: low, importance: low