[omniORB] Using octet as a union discriminator type in IDL

Sai-Lai Lo S.Lo@orl.co.uk
Tue, 25 Aug 1998 20:38:21 +0100


A while ago I acknowledged on this list that it is a bug in omniidl2 to not
accepting octet as a union discriminator type in IDL. The bug has been
fixed.

After thinking about this again, I'm not absolutely sure this is the
correct thing to do:

1. OMG IDL spec. does not list octet as a valid discriminator type.
   This may seem odd because all other scaler types are listed. One tends
   to assume that this may be one of the omission in the spec. that should
   be cleaned up eventually.

2. On the otherhand, allowing an octet as a discriminator type introduces
   an ambiguity in the typecode interface. This may just be the reason why
   octet was deliberately excluded from the list of valid discriminator
   types in the first place.

   In the typecode interface, the operation:

         Any member_label(in unsigned long index) raises (BadKind,Bounds);

   returns the label of a union member identified by index.
   *If the member is the default member, the label is the zero octet.*
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^

   Now if we have a union:

            union X switch(octet) {
               case 0: long l;
               default: short s;
            };

   Then the label of both member would be the same (zero octet)!

   This in itself is not a major problem except when you have a generic
   program that rely on looking for zero octet as the default member of a
   union!


I'll not revert the fix, i.e. omniidl2 will accept octet as union
discriminator type. However, I'll advice everyone to avoid using the type
in this way to avoid the ambiguity. 


Regards,

Sai-Lai

------------------------------------------------------------------------------
Dr. Sai-Lai Lo                          |       Research Scientist
                                        |
E-mail:         S.Lo@orl.co.uk          |       Olivetti & Oracle Research Lab
                                        |       24a Trumpington Street
Tel:            +44 223 343000          |       Cambridge CB2 1QA
Fax:            +44 223 313542          |       ENGLAND