I'm not sure that `_.` reads very well; it rather seems to denote that there is no module name.
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't believe it is a commonly seen design pattern, though, is it? On Mon, Jun 20, 2016 at 11:16 Félix Cloutier <swift-evolution@swift.org> wrote: > If no one has anything to say, I'll be starting a proposal to introduce > the _.Module.Type syntax. > > > Félix > > Le 17 juin 2016 à 19:52:45, Félix Cloutier via swift-evolution < > swift-evolution@swift.org> a écrit : > > Hello all, > > I recently ran into a bug <http://stackoverflow.com/q/37892621/251153> 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 already been reported > <https://bugs.swift.org/browse/SR-898>. > > Here's an example with Károly Lőrentey's BTree module (which also contains > a BTree type) that I encountered while trying to use the OrderedSet type: > > let set = OrderedSet<Int>()// error: 'OrderedSet' is ambiguous for type > lookup in this context// Found this candidate: Foundation.OrderedSet:3:14// > Found this candidate: BTree.OrderedSet:12:15 > > To solve this, you would normally write BTree.OrderedSet, but now Swift > thinks that BTree is the BTree type, not the BTree module: > > let set = BTree.OrderedSet<Int>()// error: reference to generic type 'BTree' > requires arguments in <...> > > Any fix will require a change to the language, and as Jordan Rose stated > on the bug, it "needs design", so I would like to bring up the issue and > discuss possible solutions. > > I can see several options (leaving "do nothing" aside, since I believe > that this needs to be resolved): > > > - Prevent modules from containing a type with the same name > - Allow modules to be imported under different names (`import BTree as > BTreeModule`, `import BTreeModule = BTree` or any similar syntax) > - Create a new syntax that indicates that you're naming a module, not > a type (like `_.BTree.OrderedSet`) > > > Thoughts? > > Félix > > _______________________________________________ > swift-evolution mailing list > swift-evolution@swift.org > https://lists.swift.org/mailman/listinfo/swift-evolution > > > _______________________________________________ > swift-evolution mailing list > swift-evolution@swift.org > https://lists.swift.org/mailman/listinfo/swift-evolution >
_______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution