module keyword with curly brackets

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Sat Nov 1 03:32:36 PDT 2014


On Saturday, November 01, 2014 07:52:38 tcak via Digitalmars-d wrote:
> The "module" declaration, and the name and path of D files do not
> need to match each other. You include a D file while compiling
> the project, and module declarations are cared only.
>
> Based on above behaviour of design, allowing only one "module"
> keyword, and that is on top of D code file seems like a
> limitation to me (a little like just trying to copy Java, but
> leaving the work in the middle).
>
> Is there any VERY SPECIAL reason behind that limitation? How hard
> would it be to add a syntax as below? What problems could it
> create?
>
> test.d
> ----
> module a{
> }
>
> module b{
>     module c{
>     }
> }

In D, packages correspond to directories, and modules correspond to files.
Yes, the module and package names can vary slightly from the file name, but
that doesn't change the fact that they still correspond to specific files, and
most folks don't give the modules names that don't match their file names.

- Jonathan M Davis



More information about the Digitalmars-d mailing list