Let's get the semantic around closure fixed.

deadalnix deadalnix at gmail.com
Thu May 20 12:53:08 UTC 2021


On Thursday, 20 May 2021 at 12:42:51 UTC, Ola Fosheim Grostad 
wrote:
> On Thursday, 20 May 2021 at 12:10:31 UTC, Adam D. Ruppe wrote:
>> It would be kinda cool if the compiler would magically pack 
>> small types into that void* sometimes. Since it is opaque to 
>> the caller it could actually pack in a captured int or two 
>> right there and be a by-value delegate.
>
> Yes, what C++ lacks is a way to type a lambda (function object) 
> before it is defined. A solution could be to have a way to say: 
> this delegate should be able to hold 2 ints and 1 double, then 
> it would have buffer space for that and there wold be no need 
> to allocate. Libraries could provide aliases that are shorter, 
> obviously.

You can do this with functors.


More information about the Digitalmars-d mailing list