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


(L Mihalkovic) #1

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@swift.org> wrote:

L. Mihalkovic via swift-evolution <swift-evolution@...> 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 :frowning:
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@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution