Let's get the semantic around closure fixed.
deadalnix
deadalnix at gmail.com
Fri May 28 13:47:32 UTC 2021
On Friday, 28 May 2021 at 02:47:41 UTC, Adam D. Ruppe wrote:
> On Friday, 28 May 2021 at 02:41:27 UTC, Q. Schroll wrote:
>> I was a little surprised that it needs the GC in the first
>> place. It's a template parameter after all.
>
> It isn't the lambda that allocates per se, it is the
> `MapResult` struct that cannot necessarily be scope since it
> doesn't know if the range will be stored or returned or
> whatever.
>
> Though perhaps if the returned map result inherited the
> lifetime of the captured variables it could work, just that
> gets complicated.
I suspect the compiler should be able to see through it after a
few rounds of inlining.
If there are so many layers that it doesn't, I suspect one
allocation isn't going to be your bottleneck.
More information about the Digitalmars-d
mailing list