Issue 9148

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 25 21:44:13 PDT 2014


On Fri, 25 Apr 2014 23:26:29 -0400, Xinok <xinok at live.com> wrote:

> On Saturday, 26 April 2014 at 01:57:06 UTC, bearophile wrote:
>> This is one of the largest problems left in the implementation of D  
>> purity:
>>
>> https://issues.dlang.org/show_bug.cgi?id=9148
>>
>> One example of the refused code:
>>
>>
>> void foo(const int[] a) {
>>     int bar() pure {
>>         return a[0];
>>     }
>> }
>> void main() {}
>>
>>
>> Bye,
>> bearophile
>
> I think this would break the D conventions of purity. 'a' is not  
> immutable, only const, meaning one or more elements could change, making  
> 'bar' impure.

It should compile. Purity in D is not the same as the more traditional  
definition of purity.

For example, this compiles:

int foo(int[] a) pure {return a[0];}

I see no difference from the above.

-Steve


More information about the Digitalmars-d mailing list