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.

Reply via email to