[swift-evolution] Operator implementation inside struct/class body

Chris Lattner clattner at apple.com
Mon Feb 1 14:39:17 CST 2016


> On Jan 31, 2016, at 11:38 PM, Goffredo Marocchi <panajev at gmail.com> wrote:
> 
>> As we do with protocols, I think we should continue to treat “func <operatoridentifier>” specially.  That said, I’d welcome other people’s thoughts on this.  Would it be more clear to have:
>> 
>> protocol P {
>> operator ==(a : Self, b : Self) -> Bool
>> }
>> 
>> Does “operator” buy us anything there over func?  If we went this direction, it would require taking operator as a keyword.
>> 
> 
> If it can help bring the feature in more painlessly then I think it is a worthy sacrifice in terms of reserving it as a keyword. It is not uncommon to see operator overloading taken as a special case anyways.

There is no semantic difference between the two, it is an aesthetic tradeoff.

-Chris


More information about the swift-evolution mailing list