Compiler analysis of single-use types? Escape analysis of types?

Yuxuan Shui via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 18 13:55:31 PDT 2016


On Thursday, 18 August 2016 at 07:04:41 UTC, Jacob Carlborg wrote:
> On 2016-08-18 03:21, Yuxuan Shui wrote:
>
>> I wish we could have something like "scoped" delegates...
>
> You mean:
>
> void foo(scope void delegate() dg);
>
> Or:
>
> void bar(void delegate() dg);
>
> scope void delegate() a = {};
> bar(a);

Delegates are pretty much a struct that holds references, right? 
So they are kinda like pointers.

I wish I can enforce scope rules (DIP1000) on them. For example, 
scope delegate should not be able to hold reference to variables 
with shorter lifetime than the delegate itself. With this we then 
could have delegates in @nogc code.


More information about the Digitalmars-d mailing list