[swift-evolution] Nil coalescing operator precedence

Xiaodi Wu xiaodi.wu at gmail.com
Wed Jun 15 08:49:56 CDT 2016


On Wed, Jun 15, 2016 at 8:43 AM, Антон Жилин <swift-evolution at swift.org>
wrote:

> `b + c * d / e` is not, obviously.
> `a ? b : c + x + y` -- I'd also say not, because, well, it's ternary
> operator, the special case that everyone should know (otherwise it looks
> like a mess with ? and : operators).
> `a ?? x + y + z` -- maybe. If not for analogies with || and && and knowing
> about @autoclosure, I'd say that priority of ?? should be very high.
>
> Now that I think about it, if job of SE-0077 could be done with a linter,
> then... do we still need it?
>

Well, I for one would veer conservative on this one and say that there is a
place for precedence in operators, if only because the mathematical ones
(the majority of them) are commonly used and unambiguous. I think SE-0077
raises some good points. But as to whether `a ?? x + y + z` should be
forced to have parentheses, you have a point here that this might be
territory for a linter.


>
> - Anton
>
> 2016-06-15 16:00 GMT+03:00 Vladimir.S <svabox at gmail.com>:
>
>> As I understand, the question is if
>>
>> `a ?? x + y + z`
>> and
>> `a ? b : c + x + y`
>> (or `b + c * d / e`)
>>
>> an "ambiguous case" ?
>>
>>
>> On 15.06.2016 15:42, Антон Жилин via swift-evolution wrote:
>>
>>> It's tempting to mention SE-0077 in this context. If it's accepted, we
>>> will
>>> be able to make omission of parentheses an error in ambiguous cases.
>>>
>>> - Anton
>>>
>>>
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution at swift.org
>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>>
>>>
>
> _______________________________________________
> 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/20160615/4ad75933/attachment.html>


More information about the swift-evolution mailing list