Name disambiguation of computed property/function with same type defined in extensions

From: Paulo Faria <paulo@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@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!

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.

Disambiguation.md · GitHub

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

···

Begin forwarded message:

On Jun 7, 2016, at 8:24 AM, Brent Royal-Gordon <brent@architechies.com> wrote:

Actually that could cause more ambiguity if a type String is created inside ModuleA or ModuleB for example. So yeah, I think “from” keyword would be the best option actually. :(

···

On Jun 7, 2016, at 5:23 PM, Paulo Faria <paulo@zewo.io> wrote:

Begin forwarded message:

From: Paulo Faria <paulo@zewo.io <mailto:paulo@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@architechies.com <mailto:brent@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@architechies.com <mailto:brent@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.

Disambiguation.md · GitHub

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