Comment #3 on issue 3755 by
astim...@gmail.com: Feature request: support
I would be very happy if inner classes were only a means of taking
advantage of lexical scoping for the organization of classes by name.
class Foo
{
Bar bar;
Baz baz;
Foo()
{
bar = new Bar();
baz = new Baz();
}
class Bar
{
}
class _Baz
{
}
}
new Foo.Bar(); // acceptable
new Foo._Baz(); // unacceptable
By "only a means of taking advantage of lexical scope" I mean to exclude
the java behaviour of creating a runtime reference to the outer class
unless the inner class is declared static. For that case the program can
explicitly provide the outer class to the inner class.
Thus the following will not work:
class Foo
{
Bar bar;
Foo()
{
bar = new Bar();
bar.speak();
}
void hello()
{
print("hello");
}
class Bar()
{
void speak()
{
hello();
}
}
}
But this will work:
class Foo
{
Bar bar;
Foo()
{
bar = new Bar(this);
bar.speak();
}
void hello()
{
print("hello");
}
class Bar
{
final Foo foo;
Bar(Foo foo)
{
this.foo = foo;
}
void speak()
{
foo.hello();
}
}
}
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings