Compiler error with static vars/functions

Jonathan M Davis jmdavisProg at gmx.com
Thu Feb 9 14:03:45 PST 2012


On Thursday, February 09, 2012 22:42:17 Oliver Plow wrote:
> Thanks for the answer. This means that all classes belonging to the same
> module must be in the same *.d file? I mean not one *.d file per class as
> in most languages?

There is no connection between modules and classes other than the fact that 
they have to go into modules (like all code in D does). You could have 1000 
public classes in the same module if you wanted to (though obviously that 
would be a maintenance nightmare). structs, classes, and free functions can 
all mix in a single module, and the module's name can be anything you want as 
long as it's a valid symbol name. It doesn't have to match any of the symbol 
names within tho module.

And I'd dispute the "most languages" bit. The only languages that I'm aware of 
which make such a connection are Java and C#, and I'm not even sure that C# is 
that strict about it (it's been a while since I programmed in C#). I believe 
that the "one public class per file" requirement is something that Java 
introduced and which is not common among programming languages in general.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list