On 11/22/17 7:35 PM, Jonathan M Davis wrote:
On Thursday, November 23, 2017 00:17:46 A Guy With a Question via
Digitalmars-d-learn wrote:
here as non-static, nested class is associated with a specific
instance of the class and has access to that class instance via
its outer member.

- Jonathan M Davis

Hmmm...now you have me very intrigued. What is a use-case where
you'd want to use a non-static embedded class? Sorry if I'm
asking too many questions. But there's a lot to dig into with
this language.

It would make sense with something like the nodes of a linked list if they
needed access to the container for some reason. Pretty much any case where a
an instance of a nested class is going to be associated with a specific
instance of its parent class and needs access to it would be a canditate.
It's not that uncommon to see cases in C++ or Java where you'd pass a
pointer to the "parent" to an instance of a nested class when it's created,
and having outer built-in is kind of like that.

The intent is exactly for porting Java code that uses either anonymous classes or inner classes.

-Steve

Reply via email to