From: Joel Baumert <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: Re: [vox] [OT] unions
X-Mailer: Mutt 1.0pre3i
A union in the C language is a special structure that allows
parts of memory to overlap.
For example:
typedef union
{
long x;
int y;
char z;
} MyUnion;
In MyUnion x, y, and z all share the same memory space. This
is useful if you have a data structure that either has a small
header to identify what is in the union or which item can be
figured out from the context it is used in.
Unions have fallen out of typical use because they can be
confusing and are a place where there can be hidden consequences
to some action. The only portability guarantee that I see from
the standard is that the last item stored can be properly
retrieved later. They are useful within a limited set of problems
because they can allow you to conserve memory with a generic
data structure...
In the context of the original post, a union is used to represent
different data types in a parser. The type of the data should be
known from the context in the parser and with that tool (bison) it
is really the only way to go.
It sounds like we agree on "labor" unions :-).
Joel