Let's get the semantic around closure fixed.

Ola Fosheim Grostad ola.fosheim.grostad at gmail.com
Thu May 20 11:40:24 UTC 2021


On Thursday, 20 May 2021 at 11:01:56 UTC, Petar Kirov 
[ZombineDev] wrote:
> On Thursday, 20 May 2021 at 09:42:20 UTC, Ola Fosheim Grostad 
> wrote:
> For past past 5-7 years, I can't think of a single new language 
> feature that required the GC. We have been going the @nogc / 
> DasBetterC road long enough (*). I think we shouldn't "skip leg 
> day" any more and we should improve a bit the high-level side 
> of D. Failing that, we should remove heap-allocated closures 
> from the language as it brings more harm to keep them working 
> wrong than not having them at all.
>
> (*) Obviously, I don't mean we should stop improving in that 
> direction (quite the opposite), but that we can afford to 
> improve in other directions as well, without diminishing our 
> current strengths.

But delegates have to work without a GC too, and C++ types dont 
like hidden allocations at all. What they do instead is utilizing 
template parameters to receive the lambda, so effctively the 
closure is stored in the "delegate".

The more I think about this the more I dislike separate 
compilation (to asm, to IR is ok). If you ditch that maybe you 
could use static analysis and store the closure in the delegate 
object.




More information about the Digitalmars-d mailing list