[swift-evolution] Proposal: Allows operator overloads in struct or classes based on return type

Tino Heth 2th at gmx.de
Sun Dec 11 05:20:17 CST 2016


imho the current behaviour is fine.

I'll leave aside infix-operators, because with pre/postfix, the situation is simpler:
It seems slightly confusing to me to declare such an operator somewhere else but at the type it works on.

Afair the ability to declare an infix operator in a type definition came with the redefinition of access levels, possibly motivated by the ability to use private properties.
This might as well be the reason not to enforce that the operator has to be defined in the type of the first operand (which I'd consider to be preferable whenever possible).


More information about the swift-evolution mailing list