<div dir="ltr">On Mon, Jun 20, 2016 at 9:08 PM, Félix Cloutier <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div>I&#39;m trying to reply to everybody in this message.</div><div><br></div><div>I think that it&#39;s a rather common and intuitive thing to name a module after its most important class, especially for small-ish packages. What would you call a package that provides a BTree, or a BigInt, and not much else?</div></div></blockquote><div><br></div><div>BTreeCore, BTreeKit, BTreePackage, MyBTree, MyBTreeCore, MyBTreeKit, MyBTreePackage...</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div>I&#39;d also make the case that ManagedObject wouldn&#39;t be an awful name for CoreData, or Animation for CoreAnimation.</div></div></blockquote><div><br></div><div>On the contrary, I think these show that some sort of prefix or suffix is greatly beneficial. IMO, Data would be an absurd package name. Note how it&#39;s WebKit, UIKit, SpriteKit and not Web, UI, Sprite.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div>If your package is big enough that it benefits from having a single class that serves as the entry point to it, it would also make sense to call it the same thing as your package.</div><div><br></div><div>I don&#39;t really like preventing modules from having a class with the same name, precisely because I think that it&#39;s an intuitive thing to do.</div><div><br></div><div>I could go with Module::Class too, given that : is not an operator character.</div><div><br></div><div>Paulo, given that I&#39;m not sure about the direction that you&#39;re taking, it&#39;s a little hard to come up with a good name. &quot;Disambiguating namespaces&quot; or &quot;namespace selection&quot; or something like that could be a good start, maybe?</div><div><span class=""><font color="#888888"><div>
<br><span style="color:rgb(0,0,0);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></font></span><div><div class="h5">
<br><div><blockquote type="cite"><div>Le 20 juin 2016 à 17:33:03, Paulo Faria &lt;<a href="mailto:paulo@zewo.io" target="_blank">paulo@zewo.io</a>&gt; a écrit :</div><br><div><div style="word-wrap:break-word">Yeah! I’m working on a formal proposal that would solve the same problem. Jordan, the problem he described is exactly like the one you explained to me, haha. Now I’m a bit confused about how the proposal should be called. Have any suggestions? What title could fit the two use cases we mentioned. By the way, can you see any other use case that would be solved with the same solution?<div><br></div><div><br><div><blockquote type="cite"><div>On Jun 20, 2016, at 9:25 PM, Jordan Rose &lt;<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>&gt; wrote:</div><br><div><div style="word-wrap:break-word"><div>I&#39;ve been encouraging Paulo Faria to mention this case in his push for a way to disambiguate extension methods, with the thought being we could then use the same syntax to differentiate top-level names as well.</div><div><br></div><div>I&#39;d also be happy with the &quot;import as&quot; syntax. The underscore syntax seems a little opaque, but I suppose it wouldn&#39;t come up very often.</div><div><br></div><div>Jordan</div><div><br></div><br><div><blockquote type="cite"><div>On Jun 17, 2016, at 19:52, Félix Cloutier via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</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></div></blockquote></div><br></div></div></div></blockquote></div><br></div></div></div></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">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>
<br></blockquote></div><br></div></div>