Issue 3755 in dart: Feature request: support for nested classes.

456 views
Skip to first unread message

da...@googlecode.com

unread,
Jun 19, 2012, 5:11:26 PM6/19/12
to bu...@dartlang.org
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 3755 by zhy...@gmail.com: Feature request: support for nested
classes.
http://code.google.com/p/dart/issues/detail?id=3755

It would be nice if we can introduce classes local to a given enclosing
class.

class Outer {
void doSomething() {
var inner = new Inner();
}
class _Inner {

}
}

This allows define class that is invisible outside of the Outer class scope.

I understand that this feature requires more investigation. As for me it
has a limited power if a class is not the first class object (or a class
could be a class member like fields or methods).




da...@googlecode.com

unread,
Jun 22, 2012, 1:38:33 PM6/22/12
to bu...@dartlang.org
Updates:
Status: Triaged
Labels: -Type-Defect Type-Enhancement Area-Language

Comment #1 on issue 3755 by seth...@google.com: Feature request: support
(No comment was entered for this change.)

da...@googlecode.com

unread,
Jun 26, 2012, 6:42:36 PM6/26/12
to bu...@dartlang.org
Updates:
Status: Accepted
Owner: gbra...@google.com
Labels: Milestone-Later

Comment #2 on issue 3755 by gbra...@google.com: Feature request: support
The idea of nested classes is very familiar to us (see. e.g., Beta,
Newspeak). To avoid any misunderstandings, I should make it clear that we
would NOT do this the way it was done in the Java programming language.
Whether this will happen in Dart is an open question.

da...@googlecode.com

unread,
Mar 26, 2014, 3:11:14 PM3/26/14
to bu...@dartlang.org

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

da...@googlecode.com

unread,
Sep 30, 2014, 10:16:32 AM9/30/14
to bu...@dartlang.org

Comment #6 on issue 3755 by PortalPr...@gmail.com: Feature request:
support for nested classes.
https://code.google.com/p/dart/issues/detail?id=3755

Any updates on this issue?

da...@googlecode.com

unread,
Oct 6, 2014, 4:57:12 PM10/6/14
to bu...@dartlang.org

Comment #7 on issue 3755 by gbr...@google.com: Feature request: support
Not really.
Reply all
Reply to author
Forward
0 new messages