digitalmars.D - nested classes
- Kris (17/17) Jun 03 2004 Thought I'd offer some clarifications regarding nested classes, since I'...
- Arcane Jill (4/8) Jun 03 2004 I didn't think of that.
- Kris (8/25) Jun 03 2004 I forgot to mention that there's an outstanding bug related to nested st...
- Blandger (4/6) Jun 04 2004 Thanks Kris for such a clarification!
- Kris (4/10) Jun 04 2004 No sweat Blanger; upload it if you like ...
- Phill (3/8) Jun 05 2004 But D's nested classes are the same as Java's nested classes.
Thought I'd offer some clarifications regarding nested classes, since I've been using them quite heavily since early March: 1) nested classes are just like nested functions. You can declare them pretty much wherever you can declare a variable. 2) nested classes are *not* the same as Java inner classes. The latter include a reference to the enclosing parent, whilst the former do not. In Java you have to know the "EnclosingClass.this.method()" incantation to reach the method of an enclosing class (from a child). In D this simply does not exist. Instead, you pass the enclosing class as a constructor argument and reference it in the normal fashion. Note that many nested classes do not need to reference the parent at all ... 3) nested classes are perfectly visible to the outside world. If you have a nested class Bar within enclosing class Foo, a simple Foo.Bar gives you the nested class. That is, new Foo.Bar(); is legitimate syntax. Such talk of "super private" is both badly misguided and misleading. 4) nested classed are the business! As are nested functions. Nice work Walter.
Jun 03 2004
In article <c9o7b0$12g0$1 digitaldaemon.com>, Kris says...3) nested classes are perfectly visible to the outside world. If you have a nested class Bar within enclosing class Foo, a simple Foo.Bar gives you the nested class. That is, new Foo.Bar(); is legitimate syntax. Such talk of "super private" is both badly misguided and misleading.I didn't think of that. <embarrassed!> Jill
Jun 03 2004
I forgot to mention that there's an outstanding bug related to nested static constructors. See the bug NG for details. "Kris" <someidiot earthlink.dot.dot.dot.net> wrote in message news:c9o7b0$12g0$1 digitaldaemon.com...Thought I'd offer some clarifications regarding nested classes, since I've been using them quite heavily since early March: 1) nested classes are just like nested functions. You can declare them pretty much wherever you can declare a variable. 2) nested classes are *not* the same as Java inner classes. The latter include a reference to the enclosing parent, whilst the former do not. In Java you have to know the "EnclosingClass.this.method()" incantation to reach the method of an enclosing class (from a child). In D this simplydoesnot exist. Instead, you pass the enclosing class as a constructor argument and reference it in the normal fashion. Note that many nested classes donotneed to reference the parent at all ... 3) nested classes are perfectly visible to the outside world. If you haveanested class Bar within enclosing class Foo, a simple Foo.Bar gives youthenested class. That is, new Foo.Bar(); is legitimate syntax. Such talk of "super private" is both badly misguided and misleading. 4) nested classed are the business! As are nested functions. Nice work Walter.
Jun 03 2004
Thanks Kris for such a clarification! I think it should be placed to Wiki. "Kris" <someidiot earthlink.dot.dot.dot.net> wrote in message news:c9o7b0$12g0$1 digitaldaemon.com...Thought I'd offer some clarifications regarding nested classes, since I've been using them quite heavily since early March:
Jun 04 2004
No sweat Blanger; upload it if you like ... "Blandger" <zeroman prominvest.com.ua> wrote in message news:c9pdtq$2rj1$1 digitaldaemon.com...Thanks Kris for such a clarification! I think it should be placed to Wiki. "Kris" <someidiot earthlink.dot.dot.dot.net> wrote in message news:c9o7b0$12g0$1 digitaldaemon.com...I'veThought I'd offer some clarifications regarding nested classes, sincebeen using them quite heavily since early March:
Jun 04 2004
"Kris" <someidiot earthlink.dot.dot.dot.net> wrote in message news:c9o7b0$12g0$1 digitaldaemon.com...Thought I'd offer some clarifications regarding nested classes, since I've been using them quite heavily since early March: 1) nested classes are just like nested functions. You can declare them pretty much wherever you can declare a variable. 2) nested classes are *not* the same as Java inner classes.But D's nested classes are the same as Java's nested classes.
Jun 05 2004