<div dir="ltr"><div>Hi,<br><br></div><div>Do anyone has any feedback about his issue? I (and at least one more user) believe that the "package.d" feature behaves strangely (please, see the examples in my original post).<br>

<br></div><div>Thanks a lot,<br><br></div><div>LMB<br></div><div><br></div>PS: I am not a big fan of "bump" posts, but I believe this message may have been ignored given some forum issues last week -- when it appeared, it was already buried under several more recent messages.<br>

<br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 18, 2014 at 10:32 AM, Leandro Motta Barros <span dir="ltr"><<a href="mailto:lmb@stackedboxes.org" target="_blank">lmb@stackedboxes.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Hello!<br><br></div>About a month ago I asked in D.learn about the expected behavior of the new package.d feature [1]. I got a cuple of responses, but not really answers. Today I noticed a second post [2] with similar but still unanswered questions. So it seemed like a good idea to bring the discussion to the main forum.<br>


<br></div><div><div>Basically, I seems that the root of the issues we are facing is the way fully-qualified names work when using package.d (I have added some examples below showing what I mean).<br><br>We also felt that the feature is under-documented (DIP37 and the changelog seem to be the only places where the feature is discussed, and some important details are missing.) I was actually about to fill bug a report about the behavior, but I ended up not doing so because I couldn't find out what the expected behavior is.<br>


<br></div><div>So, any feedback and clarifications are welcome!<br><br></div><div>Thanks for the attention, and keep up the great work :-)<br></div><div><br></div><div></div><div>LMB<br><br>[1] <a href="http://forum.dlang.org/thread/CANY+vSMzLJ5ehKGW8cE1KkoMOm7x3roKmVgMjyCqZrwD9aLO9w@mail.gmail.com" target="_blank">http://forum.dlang.org/thread/CANY+vSMzLJ5ehKGW8cE1KkoMOm7x3roKmVgMjyCqZrwD9aLO9w@mail.gmail.com</a><br>


[2] <a href="http://forum.dlang.org/thread/eeaslvjwenkygwszqznc@forum.dlang.org" target="_blank">http://forum.dlang.org/thread/eeaslvjwenkygwszqznc@forum.dlang.org</a><br><br><br>-----------------------<br><br></div><div>

EXAMPLE 1: Trying to simply replace the old "all.d" idiom with package.d doesn't work out-of-the-box:<br>
<br>Originally, I had something like this:<br><br> // mylib/util.d:<br> module mylib.util;<br> class Foo { }<br><br> // mylib/all.d:<br> module mylib.all;<br> public import mylib.util;<br><br> // main.d:<br> import mylib.all;<br>


 void main()<br> {<br>    auto f = new mylib.util.Foo;<br> }<br><br>And this used to work. Now, I added a new file:<br><br> // package.d<br> module mylib;<br> public import mylib.util;<br><br>And changed the 'import' in the main one:<br>


<br> // main.d<br> import mylib;<br><br> void main()<br> {<br>    auto f = new mylib.util.Foo;<br> }<br><br>Now, the compiler complains:<br><br> main.d(5): Error: undefined identifier 'util'<br> main.d(5): Error: mylib.util.Foo is used as a type<br>


<br></div><div>[Using mylib.Foo instead of mylib.util.Foo works -- which makes sense when thnking about the use case of using package.d to split a large package into smaller ones. ]<br></div><div><br><br>---------------------<br>


<br></div><div>EXAMPLE 2: Inconsistency with fully-qualified names<br><br>// mylib/util.d<br>module mylib.util;<br>class Foo { }<br><br>// mylib/package.d<br>module mylib;<br>public import mylib.util;<br><br>// main.d<br>


import std.stdio;<br>import mylib;<br><br>void main()<br>{<br>   auto f = new mylib.Foo;<br>   writefln("%s", <a href="http://f.classinfo.name" target="_blank">f.classinfo.name</a>);<br>}<br><br>This prints 'mylib.util.Foo'. So far so good, that's the name I originally expected.<br>


<br>Then I try to instantiate a 'Foo' using this very fully-qualified name the compiler told me:<br><br>   auto f = new mylib.util.Foo;<br><br>And DMD doesn't like it anymore:<br><br>main.d(6): Error: undefined identifier 'util'<br>


main.d(6): Error: mylib.util.Foo is used as a type<br><br></div><div>[This looks very much like a bug for me. The name given by <a href="http://classinfo.name" target="_blank">classinfo.name</a> should be usable to instantiate a class, shouldn't it? ]<br>


</div><div><br><br></div></div></div>
</blockquote></div><br></div></div>