[swift-evolution] Name disambiguation of computed property/function with same type defined in extensions
Vladimir.S
svabox at gmail.com
Thu Jun 9 08:00:40 CDT 2016
FWIW I don't like the variant with 'from' keyword. Such syntax is too
verbose for me, this syntax requires braces, I need to parse whole contents
between braces to find out what is going here, we don't use words to
represent hierarchy i.e. when calling methods/props of instance or
referencing nested types (Type1.Type2).
IMO the best solution will be '::' as separator, so
("hello swift”.module() from ModuleA)
will be :
"hello swift”.ModuleA::module()
On 08.06.2016 22:50, Paulo Faria via swift-evolution wrote:
> I’m thinking I’ll just go ahead and create a formal proposal with this:
>
> Given
> ModuleA
> extension String {
> public func module() -> String {
> return "ModuleA"
> }
> }
>
> ModuleB
> extension String {
> public func module() -> String {
> return "ModuleB"
> }
> }
>
> Problem
> ModuleC
> import ModuleA
> import ModuleB
>
> let module = "hello swift”.module() // ambiguous
>
> Proposal
> ModuleC
> import ModuleA
> import ModuleB
>
> let moduleA = ("hello swift”.module() from ModuleA)
> print(moduleA) // prints "ModuleA"
>
> let moduleB = ("hello swift”.module() from ModuleB)
> print(moduleB) // prints "ModuleB"
>
> let chainingExample = ("hello swift”.module() from ModuleB).uppercased()
> print(chainingExample) // prints "MODULEB"
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
More information about the swift-evolution
mailing list