| |
 | Posted by Q. Schroll in reply to Max Haughton | Permalink Reply |
|
Q. Schroll 
Posted in reply to Max Haughton
| On Friday, 21 May 2021 at 00:54:27 UTC, Max Haughton wrote:
> On Friday, 21 May 2021 at 00:31:52 UTC, TheGag96 wrote:
> The delegate-related thing I really want improved is being able to capture local variables in places like:
int i = 3;
someRange.map!(x => x.thing == i).each!writeln;
...without needing the GC, since we "know" that i doesn't escape. Dunno if that's a pipe dream, though.
This has to be an aim. It's simply stupid that using map in the way it's intended to be used results in a GC allocation (there are workarounds, but this is missing the point entirely). I know it won't be easy, but quite frankly if it's not possible that's a knock on us and our infrastructure - if we can't do big and important things properly we need to change that too.
I was a little surprised that it needs the GC in the first place. It's a template parameter after all. Here, it even seems a runtime delegate parameter would shine since it could be marked scope . If nothing else goes on, an allocation is not necessary. It's even @nogc . (Maybe the lambda bound to the alias could have scope implied?)
|