Global const variables
Minas Mina via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Oct 21 01:22:09 PDT 2014
On Tuesday, 21 October 2014 at 08:02:52 UTC, bearophile wrote:
> Currently this code gets rejected:
>
> const int[] a = [1];
> void main() pure {
> auto y = a[0];
> }
>
>
> test2.d(3,14): Error: pure function 'D main' cannot access
> mutable static data 'a'
> test2.d(3,14): Error: pure function 'D main' cannot access
> mutable static data 'a'
>
> But is this a good idea? Isn't it better to accept it?
>
> Bye,
> bearophile
Aren't pure functions supposed to return the same result every
time? If yes, it is correct to not accept it.
More information about the Digitalmars-d-learn
mailing list