blocks with attributes vs inlined lambda

deadalnix deadalnix at gmail.com
Mon Jun 17 19:07:55 PDT 2013


On Monday, 17 June 2013 at 19:05:07 UTC, monarch_dodra wrote:
> # Purity
> Because a lambda needs to access the frame, any function using 
> the lambda trick can't be made pure:
> void foo(T)(T a) @safe
> {
>     (){
>         ++a;
>     }();
> }
> Error: pure function 'main.foo' cannot call impure function 
> literal '__lambda1'
>

In case of lambda, purity does the wrong thing. The behavior is 
bogous.


More information about the Digitalmars-d mailing list