Assigning global and static associative arrays
Timon Gehr
timon.gehr at gmx.ch
Sun Sep 2 09:33:01 PDT 2012
On 09/02/2012 06:26 PM, monarch_dodra wrote:
> On Sunday, 2 September 2012 at 16:20:16 UTC, Timon Gehr wrote:
>> On 09/02/2012 03:45 PM, monarch_dodra wrote:
>>>
>>> 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...?
>>
>> - If there is no need to access it at run time.
>> - Type deduction.
>
> -Type deduction: Not really, I can just declare it as "immutable auto".
enum x = 2;
void main(){
auto y = x;
y = 3;
}
> -no need to access it at run time. I guess.
More information about the Digitalmars-d-learn
mailing list