[swift-evolution] Fwd: Name disambiguation of computed property/function with same type defined in extensions

Paulo Faria paulo at zewo.io
Tue Jun 7 15:23:23 CDT 2016



> Begin forwarded message:
> 
> From: Paulo Faria <paulo at zewo.io>
> Subject: Re: [swift-evolution] Name disambiguation of computed property/function with same type defined in extensions
> Date: June 7, 2016 at 4:08:16 PM GMT-3
> To: Brent Royal-Gordon <brent at architechies.com>
> 
> Yeah! I really like that option. no new keyword and it makes a lot of sense cause look at the error message:
> 
> error: ambiguous use of 'capitalized()'
> let capitalized = "hello swift".capitalized()
>                  ^
> ModuleA.String:2:17: note: found this candidate
>    public func capitalized() -> String
>                ^
> ModuleB.String:2:17: note: found this candidate
>    public func capitalized() -> String
> 
> 
> Specifically ModuleA.String:2:17 and ModuleB.String:2:17. So it seems to me that Brent's proposal makes a lot of sense actually!
> 
>> On Jun 7, 2016, at 8:24 AM, Brent Royal-Gordon <brent at architechies.com> wrote:
>> 
>>> I want to discuss the problem of name ambiguity when a computed property or function is defined with the same name and type in different modules. Currently there’s no way to disambiguate the implementation in use cases similar to the one contained in the gist below.
>>> 
>>> https://gist.github.com/paulofaria/f48d0b847a0fb7c125d163d0e349500a
>>> 
>>> The gist also contains some informal proposals. The idea is to create a formal proposal based on the discussion that shall follow.
>> 
>> We already have the concept of prefixing a type name with a module to disambiguate when two modules have the same type. I wonder if we could do the same thing to disambiguate between conflicting extensions?
>> 
>> 	import ModuleA
>> 	import ModuleB
>> 	
>> 	("hello world" as ModuleA.String).capitalized()	// Swift.String, with only APIs known to ModuleA
>> 	("hello world" as ModuleB.String).capitalized()	// Swift.String, with only APIs known to ModuleB
>> 	"hello world".capitalized()					// Still causes a compile-time error for ambiguity
>> 
>> -- 
>> Brent Royal-Gordon
>> Architechies
>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160607/03ca7923/attachment.html>


More information about the swift-evolution mailing list