Compiler error with static vars/functions
Mike Parker
aldacron at gmail.com
Thu Feb 9 20:00:31 PST 2012
On 2/10/2012 6:42 AM, 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?
>
> Regards, Oliver
>
Actually, yes. You can't have two modules of the same name. In D,
'module' is synonymous with 'file'. However, you also have packages at
your disposal. And 'package' is synonymous with 'directory'. So you can
keep one class per module (should you choose to do so) and group them
all under a common package name.
So given the directory foo with two files:
foo
- bar.d
- baz.d
You would have this in bar.d:
module foo.bar;
And then in baz.d
module foo.baz
Then you can put your Bar class in bar.d and your Baz class in baz.d if
that's the approach you prefer.
More information about the Digitalmars-d-learn
mailing list