pureity of closures

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Sun Mar 22 11:24:31 PDT 2015


On Sun, 22 Mar 2015 12:58:23 +0000, Stefan Koch wrote:

> dmd infers function closures impure if impure functions are defined
> within them.
> even if those are never called and can never be accessed outside of the
> closure.
> 
> Example :
> 
> int a;
> void closure() pure {
>    impure_function() {
>      a++;
>     }
> }
> t.d(4): Error: pure function 't.closure.impure_function' cannot access
> mutable static data 'a'
> 
> is this intended ?

i think it is. you can't do anything with `impure_function` anyway.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150322/b6eafe2e/attachment.sig>


More information about the Digitalmars-d mailing list