Thread overview
Nested class defined in another file
Jun 03, 2013
Bruno Deligny
Jun 03, 2013
bearophile
Jun 03, 2013
Bruno Deligny
Jun 03, 2013
Ali Çehreli
Jun 04, 2013
Flamaros
Jun 03, 2013
bearophile
June 03, 2013
Hi,

I want to separate nested classes in multiple files to increase readability but i need to keep the access to parent members.
Is it possible?

Thx
June 03, 2013
Bruno Deligny:

> I want to separate nested classes in multiple files to increase readability but i need to keep the access to parent members.
> Is it possible?

This is a solution, but it's not nice:

mixin(import("filename1"));
mixin(import("filename2"));
...

Why do you need so much/so many nested classes?

Bye,
bearophile
June 03, 2013
On Monday, 3 June 2013 at 22:07:15 UTC, bearophile wrote:
> Bruno Deligny:
>
>> I want to separate nested classes in multiple files to increase readability but i need to keep the access to parent members.
>> Is it possible?
>
> This is a solution, but it's not nice:
>
> mixin(import("filename1"));
> mixin(import("filename2"));
> ...
>
> Why do you need so much/so many nested classes?
>
> Bye,
> bearophile

I only have 5 classes nested into one but it sufficient to make the code difficult to read.

I began to separate them by hand by passing a parent reference but it's ugly because i need to make the parent members accessible in public to have acces. Is there any "friend" like in C++ to keep them private to others?
June 03, 2013
On 06/03/2013 03:20 PM, Bruno Deligny wrote:

> I began to separate them by hand by passing a parent reference but it's
> ugly because i need to make the parent members accessible in public to
> have acces. Is there any "friend" like in C++ to keep them private to
> others?

Have you considered the 'package' access specifier? It allows access to the modules of the same package but not to others.

Ali

June 03, 2013
Bruno Deligny:

> Is there any "friend" like in C++ to keep them private to others?

In D there is no C++ friend nor classes split as in C#. D Classes are supposed to be written in a single file. I have shown you a rough solution with import. Maybe others will give you more suggestions.

Bye,
bearophile
June 04, 2013
On Monday, 3 June 2013 at 22:39:39 UTC, Ali Çehreli wrote:
> On 06/03/2013 03:20 PM, Bruno Deligny wrote:
>
> > I began to separate them by hand by passing a parent
> reference but it's
> > ugly because i need to make the parent members accessible in
> public to
> > have acces. Is there any "friend" like in C++ to keep them
> private to
> > others?
>
> Have you considered the 'package' access specifier? It allows access to the modules of the same package but not to others.
>
> Ali

It seems exactly what we are looking for. Thx.