Thread overview
nested classes
Jun 03, 2004
Kris
Jun 03, 2004
Arcane Jill
Jun 03, 2004
Kris
Re: nested classes - Thanks!
Jun 04, 2004
Blandger
Jun 04, 2004
Kris
Jun 06, 2004
Phill
June 03, 2004
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.


June 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


June 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 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.
>
>


June 04, 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:



June 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...
> > Thought I'd offer some clarifications regarding nested classes, since
I've
> > been using them quite heavily since early March:
>
>
>


June 06, 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.