digitalmars.D - Ability to access the "outer this" pointer for nested classes planned?
- Jarrett Billingsley (7/7) Jul 13 2005 Sorry, but I don't know if this is implemented in Java, which D's nested...
- Dejan Lekic (9/9) Jul 14 2005 Jarrett, there are other much older languages that has nested classes...
- Jarrett Billingsley (3/5) Jul 14 2005 Oh well. That's OK by me.
- Ulrik Mikaelsson (8/16) Jul 20 2005 Actually, I would like to ask the same question?
- Carlos Santander (6/15) Jul 20 2005 I think there's a way to access the outer class, so probably this
- Ulrik Mikaelsson (9/17) Jul 21 2005 On a possibly related topic:
- Jarrett Billingsley (5/12) Jul 21 2005 Any function that creates a MyError must be a non-static member function...
Sorry, but I don't know if this is implemented in Java, which D's nested classes are based upon. But what I'm wondering if there is any plans for an "outer" member available for nested classes. It seems a bit strange that nested classes are implicitly associated with a certain instance of their outer class, but we can't access the pointer to the outer class. We must pass that as a parameter to the inner class's ctor. I don't know how an .outer member would behave for classes nested in functions, however..
Jul 13 2005
Jarrett, there are other much older languages that has nested classes... Java "borrowed" ideas from them, as well as D. Kind regards Dejan -- ........... Dejan Lekic http://dejan.lekic.org
Jul 14 2005
"Dejan Lekic" <leka entropy.tmok.com> wrote in message news:db5i0h$2hfm$1 digitaldaemon.com...Jarrett, there are other much older languages that has nested classes... Java "borrowed" ideas from them, as well as D.Oh well. That's OK by me.
Jul 14 2005
Jarrett Billingsley wrote:Sorry, but I don't know if this is implemented in Java, which D's nested classes are based upon. But what I'm wondering if there is any plans for an "outer" member available for nested classes. It seems a bit strange that nested classes are implicitly associated with a certain instance of their outer class, but we can't access the pointer to the outer class. We must pass that as a parameter to the inner class's ctor. I don't know how an .outer member would behave for classes nested in functions, however..Actually, I would like to ask the same question? The main reason that I see for nested classes is when there is a very tight coupling between the classes, such as for instance an exception generated in a class. It seems illogical to hide this coupling when it's already there. Regards / Ulrik
Jul 20 2005
Jarrett Billingsley escribió:Sorry, but I don't know if this is implemented in Java, which D's nested classes are based upon. But what I'm wondering if there is any plans for an "outer" member available for nested classes. It seems a bit strange that nested classes are implicitly associated with a certain instance of their outer class, but we can't access the pointer to the outer class. We must pass that as a parameter to the inner class's ctor. I don't know how an ..outer member would behave for classes nested in functions, however..I think there's a way to access the outer class, so probably this should've been in D.learn. The problem is that I also don't know how to do that. Anybody cares to answer? -- Carlos Santander Bernal
Jul 20 2005
On a possibly related topic: On compilation, the attached program causes an error: [rawler gunther ~]$ dmd nesting.d nesting.d(19): no 'this' for nested class MyError How shall I interpret this? Is it not possible to declare an inner class to be an Exception? Or am I doing something wrong? Regards / Ulrik Jarrett Billingsley wrote:Sorry, but I don't know if this is implemented in Java, which D's nested classes are based upon. But what I'm wondering if there is any plans for an "outer" member available for nested classes. It seems a bit strange that nested classes are implicitly associated with a certain instance of their outer class, but we can't access the pointer to the outer class. We must pass that as a parameter to the inner class's ctor. I don't know how an .outer member would behave for classes nested in functions, however..
Jul 21 2005
"Ulrik Mikaelsson" <rawler rsn.bth.se> wrote in message news:dbovkm$2qr8$1 digitaldaemon.com...On a possibly related topic: On compilation, the attached program causes an error: [rawler gunther ~]$ dmd nesting.d nesting.d(19): no 'this' for nested class MyError How shall I interpret this? Is it not possible to declare an inner class to be an Exception? Or am I doing something wrong?Any function that creates a MyError must be a non-static member function of A. No other function may create a MyError. That's the simplest explanation.
Jul 21 2005