Swift is all about values and protocols, so I was thinking about smthg like
this:
enum OperatorAssociativity { case left, right }
enum PrecedenceGroup {
casedefaultGroup(OperatorAssociativity)
indirect case strongerThan(OperatorAssociativity,PrecedenceGroup)
indirect case weakerThan(OperatorAssociativity,PrecedenceGroup)
indirect case between(OperatorAssociativity, strongerThan: PrecedenceGroup,
weakerThan: PrecedenceGroup)
}
let Additive: PrecedenceGroup = .defaultGroup(.left)
let Multiplicative: PrecedenceGroup = .strongerThan(.left, Additive)
let Exponentiative: PrecedenceGroup = .strongerThan(.left, Multiplicative)
let SomeOtherGroup: PrecedenceGroup = .between(.right, strongerThan:
Multiplicative, weakerThan: Exponentiative)
standard Swift, which makes it easier to reflect when the api gets created in
4.0
Regards
LM
(From mobile)
> On Jun 24, 2016, at 2:47 PM, Anton Zhilin via swift-evolution
> <[email protected]> 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 :(
> If you mean something like this:
>
> protocol PrecedenceGroup_Additive {
> associatedtype StrongerThan_Comparative
> associatedtype WeakerThan_Multiplicative
> }
>
> Then this is just ugly.
>
> _______________________________________________
> swift-evolution mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution