Assigning global and static associative arrays
monarch_dodra
monarchdodra at gmail.com
Sun Sep 2 06:45:27 PDT 2012
On Saturday, 1 September 2012 at 09:16:30 UTC, Jonathan M Davis
wrote:
> [SNIP]
> so it looks like not only do all instances of the same string
> enum use the
> same memory, but another enum with the same string literal
> shares it as well.
> So, only one is allocated. And on Linux at least, as I
> understand it, the
> string literals go in ROM. But it may be that the above code
> functions
> differently in Windows, since it _doesn't_ put string literals
> in ROM.
> [SNIP]
FYI: I get the exact same behavior in Windows. Not that it
matters, but it sounded like you were asking.
I'm a bit confused now though: Why would someone want to use an
enum when they could use a static immutable instead?
If I understood correctly, the enum will *always* be inlined
(doesn't create any actual symbols). But if you use a static
immutable, then the compiler will create an actual symbol, but
probably inline it away if it judges that is a better choice
anyways...
Is there *any* scenario where one would choose the enum over the
static immutable...?
More information about the Digitalmars-d-learn
mailing list