How to break module into multiple file.

Jonathan M Davis jmdavisProg at gmx.com
Thu May 12 11:34:34 PDT 2011


> > For small projects this is OK, but for large - not quite, IMHO.
> 
> I don't know about that. I always compile everything at once
> now - in my experience, it's negligibly slower than linking alone.
> 
> druntime: compiled all at once takes ~1 second on my box. 65k lines of
> (light) code.
> 
> phobos: compiled all at once takes ~1 second. 150k loc.
> 
> my web app for work: 3 seconds, all at once. 50k loc, does some crazy
> stuff.
> 
> 
> Maybe million line programs will be unacceptably slow, but I don't
> know, I'd have to actually see it being a problem in practice
> before I get worked up about it. tbh I wouldn't be surprised if
> the incremental build was actually slower than the all at once in
> a lot of situations.
> 
> (Though, naming the packages and modules to match the filesystem is
> a small cost anyway - it makes it easier to find the files so usually
> the best choice anyway.)

It was designed that way to make finding and managing the files easier. The 
compiler is actually able to locate modules easily and reliably. It's 
generally easy for _you_ to find them too, because the import tells you where 
they are (the fact that you can have multiply directories being searched for 
imports being the main complicating factor). It's what pretty much any D 
programmer will expect. Doing anything else will just cause confusion. Sure, 
you can do whatever you want with your own code, but I would definitely advise 
just following the normal directory structure with modules rather than trying 
to mess around with it. It is the way that it is for a reason.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list