module keyword with curly brackets

Nicolas Sicard via Digitalmars-d digitalmars-d at puremagic.com
Sat Nov 1 07:03:50 PDT 2014


On Saturday, 1 November 2014 at 10:32:48 UTC, Jonathan M Davis 
via Digitalmars-d wrote:
> 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

What's the reason why the module keyword was introduced in the 
first place? The package and module hierarchy could have been 
deduced from the directory and file hierarchy, as it is the case 
in Python, IIRC. The search rules just have to be clear. I know 
this has the side effect that module names can't be keywords or 
non-identifiers, but who would use such module names?

-- Nicolas


More information about the Digitalmars-d mailing list