6 ms·
I don't know Swift, but does this mean there are expressions in Swift where the compiler returns an error, because the expression is ambiguous without additiona
by daniellehmann 5y ago
I don't know Swift, but does this mean there are expressions in Swift where the compiler returns an error, because the expression is ambiguous without additional parentheses?
(My understanding of the article is that it mainly argues for _partial_ precedence, not so much that precedence/associativity can be defined in the program - the latter is also the case in other languages, e.g., Haskell.)
- superlopuh 5y agoYes: precedencegroup MyPrecedence {} infix operator +++: MyPrecedence func +++ (lhs: Int, rhs: Int) -> Int { lhs + rhs } let a = 1 + 2 +++ 3 Error: Adjacent operators are in unordered precedence groups 'AdditionPrecedence' and 'MyPrecedence'
- daniellehmann 5y agoVery cool, thanks a lot for the example!