Global const variables

safety0ff via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Oct 21 01:48:07 PDT 2014


On Tuesday, 21 October 2014 at 08:25:07 UTC, bearophile wrote:
> Minas Mina:
>
>> Aren't pure functions supposed to return the same result every 
>> time? If yes, it is correct to not accept it.
>
> But how can main() not be pure? Or, how can't the 'a' array be 
> immutable?
>
> Bye,
> bearophile

There can exist a mutable reference to a's underlying memory:

const int[] a;
int[] b;

static this()
{
     b = [1];
     a = b;
}


More information about the Digitalmars-d-learn mailing list