Let's get the semantic around closure fixed.

Steven Schveighoffer schveiguy at gmail.com
Thu May 20 12:31:00 UTC 2021


On 5/19/21 9:02 AM, Steven Schveighoffer wrote:

> Of course, with Walter's chosen fix, only allowing capture of non-scoped 
> variables, all of this is moot. I kind of feel like that's a much 
> simpler (even if less convenient) solution.

After reading a lot of this discussion, I have changed my mind. We 
should implement the "correct" thing even if it performs poorly. While 
Walter's solution gets the compiler out of responsibility, it doesn't 
square with the fact that closures are already hidden allocations, so 
consistency dictates we deal with inner allocations the same way.

We need one heap block per scope that has captured variables. Expensive, 
but I don't see a way around it. Hopefully optimizers and scope 
delegates can alleviate performance issues.

-Steve


More information about the Digitalmars-d mailing list