I&#39;m not sure that `_.` reads very well; it rather seems to denote that there is no module name.<br><br>The most conservative change would be to prohibit module names that collide with a contained (public) type. If, later, this is found to be unduly restrictive, another syntax can be designed and added. I don&#39;t believe it is a commonly seen design pattern, though, is it?<br><br><div class="gmail_quote"><div dir="ltr">On Mon, Jun 20, 2016 at 11:16 Félix Cloutier &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">If no one has anything to say, I&#39;ll be starting a proposal to introduce the _.Module.Type syntax.</div><div style="word-wrap:break-word"><br><div>
<br><span style="color:rgb(0,0,0);font-family:&#39;Lucida Grande&#39;;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none">Félix</span>
</div></div><div style="word-wrap:break-word">
<br><div><blockquote type="cite"><div>Le 17 juin 2016 à 19:52:45, Félix Cloutier via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; a écrit :</div><br><div><div style="word-wrap:break-word">Hello all,<div><br></div><span>I recently </span><a href="http://stackoverflow.com/q/37892621/251153" target="_blank">ran into a bug</a><span> that leaves me unable to fully-qualify the name of a type. If you import a module named Foo that also contains a type named Foo, attempts to fully-qualify any name in the Foo module will instead attempt to find something inside the Foo type. This bug has </span><a href="https://bugs.swift.org/browse/SR-898" target="_blank">already been reported</a><span>.<br></span><div><br></div><div>Here&#39;s an example with Károly Lőrentey&#39;s BTree module (which also contains a BTree type) that I encountered while trying to use the OrderedSet type:</div><div><br></div><div><pre style="margin-top:0px;padding:5px;border:0px;font-size:13px;width:auto;max-height:600px;overflow:auto;font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,sans-serif;background-color:rgb(239,240,241);color:rgb(57,51,24);word-wrap:normal"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,sans-serif;white-space:inherit"><span style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">let</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">set</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">=</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">OrderedSet</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">&lt;</span><span style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Int</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">&gt;()</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
</span><span style="margin:0px;padding:0px;border:0px;color:rgb(133,140,147)">// error: &#39;OrderedSet&#39; is ambiguous for type lookup in this context</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
</span><span style="margin:0px;padding:0px;border:0px;color:rgb(133,140,147)">// Found this candidate: Foundation.OrderedSet:3:14</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
</span><span style="margin:0px;padding:0px;border:0px;color:rgb(133,140,147)">// Found this candidate: BTree.OrderedSet:12:15</span></code></pre><div>To solve this, you would normally write BTree.OrderedSet, but now Swift thinks that BTree is the BTree type, not the BTree module:</div><div><br></div><div><pre style="margin-top:0px;padding:5px;border:0px;font-size:13px;width:auto;max-height:600px;overflow:auto;font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,sans-serif;background-color:rgb(239,240,241);color:rgb(57,51,24);word-wrap:normal"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,sans-serif;white-space:inherit"><span style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">let</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">set</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">=</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">BTree</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">OrderedSet</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">&lt;</span><span style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Int</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">&gt;()</span><span style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
</span><span style="margin:0px;padding:0px;border:0px;color:rgb(133,140,147)">// error: reference to generic type &#39;BTree&#39; requires arguments in &lt;...&gt;</span></code></pre><div>Any fix will require a change to the language, and as Jordan Rose stated on the bug, it &quot;needs design&quot;, so I would like to bring up the issue and discuss possible solutions.</div></div><div><br></div><div>I can see several options (leaving &quot;do nothing&quot; aside, since I believe that this needs to be resolved):</div><div><br></div><div><ul><li>Prevent modules from containing a type with the same name</li><li>Allow modules to be imported under different names (`import BTree as BTreeModule`, `import BTreeModule = BTree` or any similar syntax)</li><li>Create a new syntax that indicates that you&#39;re naming a module, not a type (like `_.BTree.OrderedSet`)</li></ul><div><br></div></div><div>Thoughts?</div><div>
<br><span style="font-family:&#39;Lucida Grande&#39;;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">Félix</span>
</div>
<br></div></div>_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></blockquote></div><br></div>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>