Let's get the semantic around closure fixed.

Max Haughton maxhaton at gmail.com
Wed May 19 00:05:52 UTC 2021


On Tuesday, 18 May 2021 at 19:37:54 UTC, deadalnix wrote:
> On Tuesday, 18 May 2021 at 17:40:17 UTC, Max Haughton wrote:
>> On Tuesday, 18 May 2021 at 16:47:03 UTC, deadalnix wrote:
>>> Long story short: 
>>> https://issues.dlang.org/show_bug.cgi?id=21929
>>>
>>> Closure do not respect scope the way they should. Let's fix 
>>> it.
>>
>> Time to consider by-value captures? Closures (specifically the 
>> way they interact with the GC) seem problematic in general, 
>> not just here.
>
> No need, but a new closure is needed for each loop iteration in 
> which there is a capture.

https://d.godbolt.org/z/r4TKPa946 this pattern shouldn't go 
through the GC for example. If the delegate can fit a pointer it 
can fit an int, so going through the GC n times is a waste even 
before a proper solution is found.


More information about the Digitalmars-d mailing list