module name inference

Timothee Cour thelastmammoth at
Mon Jul 15 11:52:56 PDT 2013

On Mon, Jul 15, 2013 at 11:31 AM, Jacob Carlborg <doob at> wrote:

> On 2013-07-15 17:45, Timothee Cour wrote:
>> currently when no module declaration is given, the module name is given
>> by the path base name (__FILE__.baseName.**stripExtension).
>> This is rarely useful (as soon as one has modules nested in packages).
>> Why not instead infer the module name from the relative path of __FILE__
>> with respect to the first directory in the import list in which __FILE__
>> is found:
>> ---- src/foo/bar.d:
>> // infers 'module;' instead of 'module bar;'
>> void barfun(){}
>> ----
>> ---- src/main.d:
>> import;
>> void main(){}
>> ----
>> dmd -Isrc src/main.d
> Why not just specify a module declaration? I always do that.

I do so as well precisely because of the current module name inference
rule. But with this proposal, it would become optional, making the code
more DRY and easier to refactor. Especially useful during development phase.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Digitalmars-d mailing list