Idea for avoiding GC for lambdas

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Wed Jun 23 15:03:41 UTC 2021


On Wednesday, 23 June 2021 at 13:43:21 UTC, Steven Schveighoffer 
wrote:
> A UDA might work.

Ok, so you use a templated filter function with a regular 
delegate for the parameter, but the delegate parameter is adorned 
with @__nogc_lambda. Then the compiler turns the @__nogc_lambda 
delegate into a context.

Compilers that don't support @__lambda will simply gc-allocate 
the lambda? So it is a nonbreaking extension.

Is that good enough? If so, then we can do it without a DIP.





More information about the Digitalmars-d mailing list