Subject: [netmod] union CLR in the way

From: Andy Bierman <[email-masked]>
Date: Fri, 19 Jun 2009 20:26:40 -0700

Hi,

I just ran into the 'no empty allowed in a union' CLR.

I know Juergen wanted this before, and now I'm implementing
a YANG-based CLI, I have another use case.

    rpc history {
      // descriptions deleted for brevity
      input {
        // default if no choice entered
        ncx:default-parm show;

        choice history-action {
          default show;

          leaf show {
            type union {
              type uint32;
              type empty;
            }
            default 25;
          }

          leaf save {
            type union {
              type string;
              type empty;
            }
            default "~/.yangcli_history";
          }

          leaf load {
            type union {
              type string;
              type empty;
            }
            default "~/.yangcli_history";
          }

          leaf clear {
            type empty;
          }
        }
      }
    }

The point is that for the show, save, and load variants
of the command, there can be 2 forms.  The empty form
will signal that the default be used, even though that
won't be the final data type.  E.g.,

    history
        [same as history show]

    history show
        [same as history show=25]

    history save
        [saves with the default name]

    history save=temp_history_file
        [saves with the specified name]

But yangdump issues fatal errors about 'empty type in a union'.

IMO, empty in a key is a problem,
but empty in a union is a feature.

Andy

---

From: Andy Bierman <[email-masked]>
Date: Fri, 19 Jun 2009 21:24:51 -0700

....
> IMO, empty in a key is a problem,

Actually, empty in a key is not a problem.

The ABNF for a key predicate now requires a value,
but XPath does not require that.

A predicate in an instance-identifier
could have the form [foo] (for empty),
or [foo='value'] (for all other types).

Andy

---

From: WashamFan <[email-masked]>
Date: Mon, 22 Jun 2009 10:17:48 +0800

Hi,

Why the empty type implies default is used?
It is no value setting that implies default is used.
If I define as, e.g.,

           leaf show {
              type unit32:
              default 25;
            }

The belowing is ture, since no value setting implies default
is used:

      history show

By the way, if show belongs to empty type, it can NOT have
any value.

washam
----- Original Message -----
From: Andy Bierman <[email-masked]>
Date: Saturday, June 20, 2009 11:27 am
Subject: [netmod] union CLR in the way
To: NETMOD Working Group <[email-masked]>

>  _______________________________________________
>  netmod mailing list
>  [email-masked]
>  https://www.ietf.org/mailman/listinfo/netmod
>

---

From: Andy Bierman <[email-masked]>
Date: Mon, 22 Jun 2009 08:37:35 -0700

>           [same as history show=25]

We should not confuse proprietary CLI encoding
with standard XML encoding.  It is not within
the charter at all.

> By the way, if show belongs to empty type, it can NOT have

In XML, we already have the feature I want, because 'string'
is allowed to be empty, which can be encoded 2 ways:

    <foo></foo>
    <foo/>

Some applications ignore XML encoding rules wrt/ significant
whitespace, so an agent might even accept this as an empty
as well:

  <foo>
  </foo>

I can do the same thing in my CLI.

  foo

  foo = ''

can mean the same thing.

So I don't care if the union/key CLRs get removed.
They are a good little test for people who think they
know YANG, but really don't.  Unfortunately, I have found
that several smart people I know read some of the drafts
and extrapolate the rest.  Their logical assumptions
are mostly wrong, since CLRs are usually illogical.

Andy