> On Apr 27, 2016, at 10:54 AM, Dave Abrahams via swift-evolution 
> <[email protected]> wrote:
> 
> 
> on Tue Apr 26 2016, Chris Lattner <[email protected]> wrote:
> 
>> On Apr 26, 2016, at 7:34 PM, Tony Allevato via swift-evolution 
>> <[email protected]> wrote:
>>> Would something like this be possible? Imagine protocols defined like this:
>>> 
>>>  public protocol Equatable {
>>>      static func == (lhs: Self, rhs: Self) -> Self
>>>  }
>> 
>> The problem is that every type that conforms to Equatable has to
>> provide an overload of == in order to conform.  This is exactly what
>> having named methods as requirements solves.
> 
> Note that Tony is proposing to make the requirement static.  Whether
> it's actually called “==” or isEqual is almost immaterial, because the
> fact that it is static makes it less likely that anyone will try to call
> it directly.  
> 
> However, if we allowed static operators to be defined, and called using
> the syntax “T.==(x,y)”, as Tony has suggested, IMO it would further
> discourage direct use, and it would avoid growing the number of
> truly distinct spellings for the same operation.

Ah, that is clever!

-Chris
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to