Thread overview
"friend"-replacement?
Apr 25, 2004
Norbert Nemec
Apr 25, 2004
J Anderson
Apr 25, 2004
Norbert Nemec
Apr 25, 2004
Ivan Senji
Apr 25, 2004
Scott Egan
Apr 25, 2004
Norbert Nemec
Apr 25, 2004
J Anderson
April 25, 2004
Hi there,

obviously, "friend" declarations from C++ do not exist in D. Is there any alternative way to implement a group of classes that interdepend on each other's internals without exposing these to the outside world?

Thanks,
Nobbi
April 25, 2004
Norbert Nemec wrote:

>Hi there,
>
>obviously, "friend" declarations from C++ do not exist in D. Is there any
>alternative way to implement a group of classes that interdepend on each
>other's internals without exposing these to the outside world?
>  
>
Modules.

-- 
-Anderson: http://badmama.com.au/~anderson/
April 25, 2004
J Anderson wrote:
> Norbert Nemec wrote:
>>obviously, "friend" declarations from C++ do not exist in D. Is there any alternative way to implement a group of classes that interdepend on each other's internals without exposing these to the outside world?
>> 
> Modules.

???

As far as I understand, you can have classes and functions private to a module or class members private to the class, but how do you make class members private to the module?
April 25, 2004
"Norbert Nemec" <Norbert.Nemec@gmx.de> wrote in message news:c6g2ft$16na$1@digitaldaemon.com...
> J Anderson wrote:
> > Norbert Nemec wrote:
> >>obviously, "friend" declarations from C++ do not exist in D. Is there
any
> >>alternative way to implement a group of classes that interdepend on each other's internals without exposing these to the outside world?
> >>
> > Modules.
>
> ???
>
> As far as I understand, you can have classes and functions private to a module or class members private to the class, but how do you make class members private to the module?

This is not possible. One module should contain only classes that are friends.


April 25, 2004
From memory private in a class is only private to the module.

See: http://www.digitalmars.com/d/attribute.html

"Norbert Nemec" <Norbert.Nemec@gmx.de> wrote in message news:c6g2ft$16na$1@digitaldaemon.com...
> J Anderson wrote:
> > Norbert Nemec wrote:
> >>obviously, "friend" declarations from C++ do not exist in D. Is there
any
> >>alternative way to implement a group of classes that interdepend on each other's internals without exposing these to the outside world?
> >>
> > Modules.
>
> ???
>
> As far as I understand, you can have classes and functions private to a module or class members private to the class, but how do you make class members private to the module?


April 25, 2004
Norbert Nemec wrote:

>As far as I understand, you can have classes and functions private to a
>module or class members private to the class, but how do you make class
>members private to the module?
>  
>

I'm not quite sure what you asking.  When you use private in a module (whether it's within a class or not) it behaves on the module level. ie

class A { private int x; }

void main()
{
   A a = new A;
   a.x = 10; //No error (if it was a different module there would be)
}

-- 
-Anderson: http://badmama.com.au/~anderson/
April 25, 2004
Scott Egan wrote:
> From memory private in a class is only private to the module.

OK, the documentation can be understood like that, but it is not very concise in this point.