Subj : Re: Why not unions To : comp.programming From : Scott Moore Date : Tue Jul 26 2005 05:48 pm Jon Harrop wrote: > Shwetabh wrote: > >>Hi, my question is related with data structures. >>Why are only structures used for implementing data structures. >>Why not unions when they are more memory efficient than structures. > > > This sounds like a question about struct and union in the C programming > language. Both struct and union are used by C programs. However, struct is > much more common than union. Also, union is unsafe and can easily be the > cause of bugs. > > Many more modern languages (like OCaml and SML) provide safe alternatives to > union called variant types. > As do older languages, such as Pascal. .