www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Nested class defined in another file

reply "Bruno Deligny" <bruno.deligny gmail.com> writes:
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
Jun 03 2013
parent reply "bearophile" <bearophileHUGS lycos.com> writes:
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
Jun 03 2013
parent reply "Bruno Deligny" <bruno.deligny gmail.com> writes:
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?
Jun 03 2013
next sibling parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
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
Jun 03 2013
parent "Flamaros" <flamaros.xavier gmail.com> writes:
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.
Jun 04 2013
prev sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
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
Jun 03 2013