Another purity question

bearophile bearophileHUGS at lycos.com
Tue Jan 14 11:50:08 PST 2014


Currently D refuses code like this:


void foo(const int[] a) {
     int bar() pure {
         return a[0];
     }
}
void main() {}


With two repeated error messages:

test1.d(3): Error: pure nested function 'bar' cannot access 
mutable data 'a'
test1.d(3): Error: pure nested function 'bar' cannot access 
mutable data 'a'


But is it possible for D to see that bar function as pure?

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list