How to break module into multiple file.

Matthew Ong ongbp at yahoo.com
Thu May 19 06:59:36 PDT 2011


On 5/14/2011 3:17 AM, Nick Sabalausky wrote:
> "Jason House"<jason.james.house at gmail.com>  wrote in message

 > But yea, one-class-per-file is really a Java thing (and then a few other
Not true entirely, the limit is one public class per file. There is no 
actual limit for such:
// The file must be ClassA.java

public class ClassA{}

class ClassB1{}
class ClassB2{}
class ClassB3{}
class ClassB4{}...


 > languages kind of ape'd it.). No need to force youself into that in D.

As for the real reason it is for:
That current D layout seem to limit that one file to a single developer. 
Instead of multiple classes by multiple developers within the same module.

Using the example:
HashMap & Unit tested implemented by matthew
LinkedList & Unit tested implemented by john
but the same module is handled by Jonathan for other classes?

But Nick,
-- ...to this: ---

// libfoo/all.d
module libfoo.all;
public import libfoo.partA;
public import libfoo.partB;
public import libfoo.partC;

That does the trick. Now my only concern is that when does D linked like 
C++ or dynamic selective linked on import that is ONLY really used and 
not linked ALL that is imported....Such thing does not happen in Java 
because linking is done during runtime by Class Loader. I wonder the 
loader in D for DLL is as intelligent.


-- 
Matthew Ong
email: ongbp at yahoo.com



More information about the Digitalmars-d-learn mailing list