On Mon, Jul 15, 2013 at 11:31 AM, Jacob Carlborg <span dir="ltr"><<a href="mailto:doob@me.com" target="_blank">doob@me.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 2013-07-15 17:45, Timothee Cour wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
currently when no module declaration is given, the module name is given<br>
by the path base name (__FILE__.baseName.<u></u>stripExtension).<br>
This is rarely useful (as soon as one has modules nested in packages).<br>
Why not instead infer the module name from the relative path of __FILE__<br>
with respect to the first directory in the import list in which __FILE__<br>
is found:<br>
<br></div><div class="im">
---- src/foo/bar.d:<br>
// infers 'module foo.bar;' instead of 'module bar;'<br>
void barfun(){}<br>
----<br>
<br>
---- src/main.d:<br>
import foo.bar;<br>
void main(){}<br>
----<br>
<br>
dmd -Isrc src/main.d<br>
</div></blockquote>
<br>
Why not just specify a module declaration? I always do that.</blockquote><div><br></div><div>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.</div>
</div>