How to let D's one module contains lots of classes.
AlanThinker via Digitalmars-d
digitalmars-d at puremagic.com
Sun Nov 9 05:17:36 PST 2014
On Sunday, 9 November 2014 at 12:21:28 UTC, tcak wrote:
> On Sunday, 9 November 2014 at 11:30:22 UTC, AlanThinker wrote:
>> Yes, you are right.
>> Package can do it.
>> Thanks all of you!
>
> Yes, package can do it, thou this adds burden to maintain
> packages this time. Weirdness of this design is seen in
> druntime as well.
>
> core.sync.mutex.Mutex
>
> Doubling mutex word unnecessarily. Every time I will create a
> module, half an hour, I am thinking what name to give the
> module. Either will create many classes in one file, or use
> same name for both module and class that causes above example.
If we can create partial module, it will be easier to use. then
no package needed.
such as:
################
// test/foo/gui/button.d
partial module foo.gui;
class Button
{
public this() {
import std.stdio : writeln;
writeln( "New Button!" );
}
}
// test/foo/gui/widget.d
partial module foo.gui;
class Widget {
public this() {
import std.stdio : writeln;
writeln( "New Widget!" );
}
}
// test/foo/namespace.d
module namespace;
import foo.gui;
void main()
{
auto w = new foo.gui.Widget;
auto b = new foo.gui.Button;
}
###############
More information about the Digitalmars-d
mailing list