[OT] modules vs filenames in "module-name == filename" package systems

Steven Schveighoffer schveiguy at yahoo.com
Tue Jun 29 12:20:17 PDT 2010


On Tue, 29 Jun 2010 14:51:49 -0400, Nick Sabalausky <a at a.a> wrote:

> In a language that has a package system that forces package names to be  
> the
> same as the directory name, and module names to be the same the file name
> (Such as Java, but not D): What is the point of having packages/modules
> instead of just simply importing by a relative filepath? Is it just so  
> that
> it's consistent with refering to a symbol by it's fully-qualified name,  
> or
> forcibly disallowing absolute paths when importing, or are there other
> reasons?

Java doesn't import source files, it imports compiled objects.  Therefore,  
the file/module relationship is superficial -- you could just as easily  
create a java compiler that can compile all packages/modules in one file.   
I think the file/directory model just is easy for people to understand and  
maintain.

D is different in that it actually requires the source for importing.

I've always hoped that D moved more towards an import model that used  
compiled objects instead of the source.  There's always the chance that  
objects are out of sync with source, and the compiler can add annotations  
for things like full escape analysis if what you import is always  
generated.

-Steve


More information about the Digitalmars-d mailing list