www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Partial modules (dictating modules)

Hi all,

Currently, D only supports modules on the file level. For small modules 
this is fine, but for modules with classes it isn't pretty working. 
Currently without splitting up the modules per class, files become 
extensively long.

As I am working on a school project with D (we may use our own 
languages, if argumented well :) ) and also use it for myself, I 
constantly struggle with very long files, searching for things become 
sometimes a little disaster.

Splitting modules per class isn't a good design and weakens the whole 
idea behind modulair (subsystem) engineering. This is why I ask to 
consider building in something like partial or dictating modules. The 
system I have in mind takes uses a master module (or simply a module) 
and dictates which child modules may be a child of it.

Similar to the following:

# file master.d:
# ----------------------------------------------------------------------
# module master;
#
# import child first;    // refers to first.d
# import child second;   // refers to second.d

# file first.d:
# ----------------------------------------------------------------------
# child first module master;
#
# class SomeClass {
#     ...
# }

# file second.d:
# ----------------------------------------------------------------------
# child second module master;
#
# class SomeOtherClass {
#     ...
# }

The master file could then be used as:

# file main.d:
# ----------------------------------------------------------------------
# module main;
#
# void main(char[][] args) {
#     // ctors master[first].SomeClass
#     SomeClass sc = new SomeClass();
#
#     // ctors master[second].SomeOtherClass
#     SomeOtherClass sc = new SomeOtherClass();
# }

Regards,
Sjoerd
Sep 19 2004