DIP 1011--extern(delegate)--Preliminary Review Round 1

Jonathan Marler via Digitalmars-d digitalmars-d at puremagic.com
Mon Jul 17 08:16:45 PDT 2017


On Sunday, 16 July 2017 at 11:45:09 UTC, Nicholas Wilson wrote:
> On Friday, 14 July 2017 at 10:43:05 UTC, Mike Parker wrote:
>> DIP 1011 is titled "extern(delegate)".
>>
>> https://github.com/dlang/DIPs/blob/master/DIPs/DIP1011.md
>>
>> All review-related feedback on and discussion of the DIP 
>> should occur in this thread. The review period will end at 
>> 11:59 PM ET on July 28 (3:59 AM GMT July 29), or when I make a 
>> post declaring it complete.
>>
>> At the end of Round 1, if further review is deemed necessary, 
>> the DIP will be scheduled for another round. Otherwise, it 
>> will be queued for the formal review and evaluation by the 
>> language authors.
>>
>> Thanks in advance to all who participate.
>>
>> Destroy!
>
> Not that it is a requirement to consider fir this DIP, but how 
> would this play with Vittorio's lambda Value capture DIP(?)?

I don't see any relation.  Looks like the lambda capture lowers 
to defining a temporary struct and assigning the captured values 
to fields in that struct, then the lambda is defined as a member 
function of that struct.  That member function already uses the 
delegate ABI where the context is a reference to the temporary 
struct.

void main()
{
     int x;
     string s;

     auto dg = [x,s]() => {
         // ...
     }
     /*
     lowers to something like this
     struct __lambda_struct__
     {
         int x;
         string s;
         // This method already has a context, cannot make it 
extern(delegate)
         void execute()
         {
             // ...
         }
     }
     auto dg = &__lambda_struct__(x, s).execute;
     */
}


More information about the Digitalmars-d mailing list