[swift-evolution] [Proposal] Custom operators

Chris Lattner clattner at apple.com
Sat Apr 9 08:39:17 CDT 2016


On Apr 8, 2016, at 12:28 PM, Антон Жилин <antonyzhilin at gmail.com> wrote:
> The question 4 (`prefix operator ! { }` or `prefix operator !`) seems dead simple, because if we need to declare precedence group in body of infix operators, then other operators should have it for consistency.
> 
> It's not.
> I suggest an alternative syntax for that:
> infix operator <> : Comparative
> 
> Colon immediately after the operator may not look the best, but it's the only disadvantage I can find. It looks like inheritance and has similar meaning.

I agree, this is an nice approach.  You’re basically saying that the <> operator is a member of the set of Comparative operators, thereby “inheriting” its precedence behaviors.

-Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160409/e63ab8f6/attachment.html>


More information about the swift-evolution mailing list