Unions? Why?

So I can kind of see where unions might have been used when computers had 1 MB ram, or less, but this is 2012! 4 GB of ram is pretty much the de facto standard anymore, and actually being kind of low. So why use unions? Or are they ever used anymore?
closed account (z05DSL3A)
So I can kind of see where unions might have been used when computers had 1 MB ram, or less, but this is 2012! 4 GB of ram is pretty much the de facto standard anymore, and actually being kind of low. So why use unions?
There are still plenty of systems out there that don't have a bucketload of memory ... but anyway do you really want a variant type to be massive just because you have the RAM to fit it in?
but anyway do you really want a variant type to be massive just because you have the RAM to fit it in?


I'm not saying this, but it seems like (I personally haven't used them) that they would lead to a lot of needed book keeping. I guess I just don't see the benefit/use of them.
4 GB of ram is pretty much the de facto standard anymore, and actually being kind of low. So why use unions?

That sounds to me like "Why we should safe the tropical rain forest? We have enough oxygen out of there!"

Some of our customer database tables are bigger than 8 GB and some analysis requires to handle with the whole data at once. Outsourcing this data on the HD would be too slow, so we map the structure in memory. I'm really sure our analytical experts are using this "useless" union thing en masse. It's a big difference when an evaluation takes "only" 12 hours instead of 26...
i program micro controllers with only 1Kb of ram ... that is not much and i use unions a lot!

4GB on a pc is standard... true.. but there are more platforms...
Ah you misunderstand me. I didn't say it was useless, I just said I personally don't see the use anymore. The database deal makes sense, I guess database entries were paged in and out of memory when needed.

1K sounds really small, even on a microcontroller. What kind of microcontrollers are you working with?
amazing --- 32 bytes of ram ;)

http://www.atmel.com/Images/doc8127.pdf
Ah you misunderstand me. I didn't say it was useless, I just said I personally don't see the use anymore.

I see, my mistake ;)
I personally use unions in structures when I'm working with sqlite2 databases. But other use cases I haven't seen yet, too.
32 bytes of ram


This is ridiculous haha. What's the ISA look like for something like this?
Topic archived. No new replies allowed.