How to let D's one module contains lots of classes.

Rikki Cattermole via Digitalmars-d digitalmars-d at puremagic.com
Sun Nov 9 00:53:09 PST 2014


On 9/11/2014 9:44 p.m., AlanThinker wrote:
> In C#, one namespace can contains lots of classes.
> How to let D's one module contains lots of classes.
> It seems that in D one module must in a single file.
> If there all classes in one file, the file will be to big.

You are correct, that one file can have a lot of classes in it.
But you are comparing the wrong things.

A namespace in c# can be between multiple files that don't even need to 
be in the same directory hierarchy.

But you can do a few things:
1) Public import other modules so that it will act as if it has it.
2) Use packages. This is probably the most comparable against a c# 
namespace. But in saying that, its really more directly comparable 
against java's package.
In that it is a directory that contains modules. But a package needs its 
own module (called package) that will act as basically public imports.

Here is an example of using both:
https://github.com/Devisualization/util/tree/master/source/opengl/devisualization/util/opengl/function_wrappers

Also this is more suitable for D.learn.


More information about the Digitalmars-d mailing list