A purity change

monarch_dodra monarchdodra at gmail.com
Thu Jul 11 13:34:53 PDT 2013


On Thursday, 11 July 2013 at 16:53:30 UTC, H. S. Teoh wrote:
> On Thu, Jul 11, 2013 at 06:31:13PM +0200, Meta wrote:
>> On Thursday, 11 July 2013 at 16:14:13 UTC, H. S. Teoh wrote:
>> >On Thu, Jul 11, 2013 at 05:25:09PM +0200, bearophile wrote:
>> >Hmm. This seems to be a tricky corner case. The delegate 
>> >itself is
>> >impure, as it accesses y which is outside of its definition 
>> >and
>> >isn't part of its arguments; however, in the larger context of
>> >spam(), this shouldn't be a problem since y is accessed via
>> >'this', and 'this' is part of spam's input.
>> 
>> Isn't it okay for pure functions to access global immutable 
>> state,
>> such as what the delegate is doing here?
>
> True, I didn't think of that. :) So in this case it looks like a
> regression.
>
>
> T

It's not a global static though. It's a member immutable, but 
accessed via the (impure) context pointer.

It should work, but it's not just straight up global immutable


More information about the Digitalmars-d-learn mailing list