Mixed closures and class.outer references

Iain Buclaw via Digitalmars-d digitalmars-d at puremagic.com
Sun Apr 12 12:36:52 PDT 2015


Hi,

Can someone tell me what is supposed to happen in Outer.foo.Inner.bar?
 And how it should look in debug?

---
class Outer
{
    int x = 42;
    void foo()
    {
        int y = 43;
        class Inner
        {
            void bar()
            {
                assert(x == 42);
                assert(y == 43);
            }
        }
        Inner b = new Inner();
        b.bar();
    }
}
---

What I'm currently seeing is:

Function: Inner.bar()
Params: (this=...)
typeof(this) == Inner
typeof(this.this) == Outer

No sign of the closure in Outer.foo, so how is 'y' even accessible?


More information about the Digitalmars-d mailing list