[swift-evolution] [Proposal] Custom operators

Haravikk swift-evolution at haravikk.me
Sun Apr 3 05:58:43 CDT 2016


> On 3 Apr 2016, at 11:45, Антон Жилин <antonyzhilin at gmail.com> wrote:
> 
> > Assuming these are defined in separate modules, how do we determine the order of • and ~?
> 
> By default, priority between any two operators is undefined. If two modules don't know about each other, but the user wishes to prioritize them, then he will write:
> 
> #precedence(•, lessThan: ~)
> 
> If • suddenly wishes to cooperate with ~, then it will add directives:
> 
> #operator(~, fixity: infix, associativity: left)
> #precedence(•, lessThan: ~)
> 
> It doesn't matter if ~ or user have already added them: if they do not contain contradictory information, there will be no conflict.

Ah, I misunderstood then, so a warning/error will be raised if no precedence exists? Thanks for the explanation! I’ll probably still favour overkill brackets, but this makes sense.

In any event I’m on +1 for the more standardised syntax and the switch to using #directives, makes a lot of sense since these are really just customisable compiler symbols.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160403/63b5cddb/attachment.html>


More information about the swift-evolution mailing list