We need to have a way to say "convert this nested function into a struct"

Atila Neves via Digitalmars-d digitalmars-d at puremagic.com
Sat Jun 6 15:35:17 PDT 2015


On Saturday, 6 June 2015 at 22:15:42 UTC, Idan Arye wrote:
> On Saturday, 6 June 2015 at 06:16:17 UTC, Andrei Alexandrescu 
> wrote:
>> Nested functions that allocate their environment dynamically 
>> can be quite useful. However, oftentimes the need is to 
>> convert the code plus the data needed into an anonymous struct 
>> that copies the state inside, similar to C++ lambdas that 
>> capture by value.
>>
>> I wonder how to integrate that within the language nicely.
>>
>>
>> Andrei
>
> My solution: http://dpaste.dzfl.pl/aa013ff51f60
>
> Can't make it @nogc though, because it thinks I'm trying to 
> capture `a` and `b`...

I forgot to do that. In my solution, functorPartial is @nogc. 
Just slapped it on and it still compiled.

Atila


More information about the Digitalmars-d mailing list