[Issue 5710] cannot use delegates as parameters to non-global template

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Jun 14 11:03:14 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=5710

--- Comment #39 from timon.gehr at gmx.ch ---
(In reply to Sobirari Muhomori from comment #38)
> (In reply to Martin Nowak from comment #34)
> > It's still challenging to implement all the IR gen for this.
> 
> BTW, looks like all the code generation was there for ages:
> 
> struct A
> {
> 	int a;
> 	int delegate() foo()
> 	{
> 		int b;
> 		int bar()
> 		{
> 			return a+b;
> 		}
> 		int delegate() d=&bar;
> 		b=1;
> 		return d;
> 	}
> }
> 
> Here nested function `bar` accesses both stack variable `b` and member field
> `a` through single context pointer in delegate `d` as if it has two contexts
> - closure pointer and `this` pointer.

This is not the same thing. Here, one context is nested in the other.

--


More information about the Digitalmars-d-bugs mailing list