Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
July 14, 2005 Ability to access the "outer this" pointer for nested classes planned? | ||||
---|---|---|---|---|
| ||||
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.. |
July 14, 2005 Re: Ability to access the "outer this" pointer for nested classes planned? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley |
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
|
July 14, 2005 Re: Ability to access the "outer this" pointer for nested classes planned? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dejan Lekic | "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. |
July 20, 2005 Re: Ability to access the "outer this" pointer for nested classes planned? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | 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
|
July 21, 2005 Re: Ability to access the "outer this" pointer for nested classes planned? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | 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 |
July 21, 2005 Re: Ability to access the "outer this" pointer for nested classes planned? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley Attachments: | 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..
|
July 21, 2005 Re: Ability to access the "outer this" pointer for nested classes planned? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ulrik Mikaelsson | "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. |
Copyright © 1999-2021 by the D Language Foundation