[swift-evolution] [Proposal] Custom operators
Chris Lattner
clattner at apple.com
Sat Apr 9 08:33:26 CDT 2016
> On Apr 8, 2016, at 5:16 AM, Rainer Brockerhoff via swift-evolution <swift-evolution at swift.org> wrote:
>> - I definitely agree that a partial ordering between precedences is all that we need/want, and that unspecified relations should be an error.
>> ...
>> Question for you: have you considered introducing named precedence groups, and having the relationships be between those groups? For example, I could see something like:
>>
>> operator group additive {}
>> operator group multiplicative { greaterThan: additive }
>> operator group exponential { greaterThan: additive }
>
> Also +10, would be interested in your opinion about:
>
> 1) disallowing adding new operator groups outside the stdlib;
>
I don’t see why we would do that. This would lead us directly into the world of C++ operator overloading, where everyone reuses existing operators instead of defining their new and unique operators. IMO it is much better to "know that you don’t know” what a symbol is, rather than assuming it has the obvious semantics and being surprised because it was overloaded.
> 2) disallowing adding operators to uncommon groups like subscripting,
> function calls, etc.
Subscripting and function calls are not operators.
-Chris
More information about the swift-evolution
mailing list