[omniORB] Union vs Any

Gary D. Duzan gdd0@gte.com
Wed, 29 Nov 2000 11:55:27 -0500


   For basic types and using an integer discriminator for the union,
the speed should be pretty close either way, so use whichever fits
you application better. If you are going to add a limited number
of more complex types or object references later, you would probably
be better off using a union. If you may need to add more of them
at various times in the future, it may be easier to use Anys and
not have to update the IDL constantly.
   The main overhead in using an Any is the need to pass the
typecode. For basic types this is only an integer or two, so there
isn't much loss. More complex types will need to have a typecode
string and/or description of the type's properties passed along
with the data, so you'd be better off avoiding Any encoding them
if speed is a concern.

					Gary Duzan
					Verizon Laboratories



In Message <3A253229.A803AD9F@eth.ericsson.se> ,
   Tamas Morvai <Tamas.Morvai@eth.ericsson.se> wrote:

=>
=>Hi,
=>
=>I'd like to use a sequence of "any"s or unions to pass
=>parameters to my application like this:
=>
=>typedef sequence<any> AnySeq;
=>
=>invoke(in AnySeq parameters);
=>
=>I will only send basic types. So, should I use "any"
=>or union (which consists of the basic types)?
=>Which is the better, faster, etc?
=>
=>/Tamas
=>
=>PS: I've read that "any" has more run-time overhead.
=>