Getting module of a class
Sergey Gromov
snake.scaly at gmail.com
Sat Oct 18 10:47:22 PDT 2008
Sat, 18 Oct 2008 11:52:38 -0500,
Andrei Alexandrescu wrote:
> Sergey Gromov wrote:
> > Sat, 18 Oct 2008 05:58:50 +0900,
> > Bill Baxter wrote:
> >> The truly simplest solution here is just to ignore Scott Meyer's
> >> advice and make nonMemberFunction a static member function. That way
> >> if I have access to SomeClass I will always have easy access to
> >> nonMemberFunction, regardless of whatever round-about chain of imports
> >> and aliases got me SomeClass.
> >
> > To define a non-member, *non-friend* function in D you must define it in
> > a different module than the module in which your class is defined. Good-
> > bye encapsulation. :)
>
> I agree. I'd also agree that file-level encapsulation does make sense.
> After all, unless fancy code databases are used, the file is the
> physical unit of protection and change tracking, and it's here to stay.
> So I don't find one scheme inferior to the other.
I'm only saying that if you are to follow Meyers' advice then ModuleOf()
won't help you because any "convenience functions" will be defined in
another module.
More information about the Digitalmars-d
mailing list