[swift-evolution] Fwd: [Returned for revision] SE-0077: Improved operator declarations

L. Mihalkovic laurent.mihalkovic at gmail.com
Fri Jun 24 09:31:32 CDT 2016


More smthg like this:

protocol PrecedGrpType{}
enum OperatorAssociativity { case left, right }
enum PrecedenceGroup {
    casedefaultGroup(OperatorAssociativity)
    indirect casestrongerThan(OperatorAssociativity,PrecedenceGroup)
    indirect caseweakerThan(OperatorAssociativity,PrecedenceGroup)
}

let Additive: PrecedenceGroup = .defaultGroup(.left)
let Multiplicative: PrecedenceGroup = .strongerThan(.left, Additive)
let Exponentiative: PrecedenceGroup = .strongerThan(.left, Multiplicative)

standard Swift, which makes it easier to reflect when the api gets created in 40

Regards
LM
(From mobile)


>> On Jun 24, 2016, at 2:47 PM, Anton Zhilin via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> L. Mihalkovic via swift-evolution <swift-evolution at ...> writes:
>> 
>>>> Could you please explain what you mean by "meta-circular syntax for
>> the 
>>>> precedence group definitions"? An example?
>>> =define it using existing swift constructs rather than by extending
>> swift with new kwd looks like grp
>>> matches a struct.
>> 
>> I still don't fully understand without an example :(
>> If you mean something like this:
>> 
>> protocol PrecedenceGroup_Additive {
>>    associatedtype StrongerThan_Comparative
>>    associatedtype WeakerThan_Multiplicative
>> }
>> 
>> Then this is just ugly.
>> 
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160624/a7704b32/attachment-0001.html>


More information about the swift-evolution mailing list