Many questions

Liang Du duliang.21 at 163.com
Mon May 4 02:06:00 PDT 2009


Nick Sabalausky Wrote:

> "Fractal" <d294934 at bsnow.net> wrote in message 
> news:gtlihm$tt0$1 at digitalmars.com...
> >
> > The namespaces: i used them with C++, and the idea of separation between 
> > the uses of types, makes a very good layout. Because some namespaces 
> > requires more types, always i write each class in separate files. D simply 
> > breaks it, making a big amount of lines for imports.
> >
> 
> That is easy to work around. Instead of this (which doesn't work in D):
> 
> -------------------------------------
> //File: foo/fooA.d
> module foo;
> class fooA {}
> 
> //File: foo/fooB.d
> module foo;
> class fooB {}
> 
> //File: foo/fooC.d
> module foo;
> class fooC {}
> 
> //File: main.d
> import foo;
> void main() {...}
> -------------------------------------
> 
> Do this:
> 
> -------------------------------------
> //File: foo/fooA.d
> module foo.fooA;
> class fooA {}
> 
> //File: foo/fooB.d
> module foo.fooB;
> class fooB {}
> 
> //File: foo/fooC.d
> module foo.fooC;
> class fooC {}
> 
> //File: foo/all.d
> module foo.all;
> public import foo.fooA;
> public import foo.fooB;
> public import foo.fooC;
> 
> //File: main.d
> import foo.all;
> void main() {...}
> -------------------------------------
> 
> This works fine and does exactly what you want.
> 


The namespaces is better !!!



More information about the Digitalmars-d mailing list