[swift-evolution] [Discussion] Breaking precedence

Xiaodi Wu xiaodi.wu at gmail.com
Mon Aug 1 16:52:50 CDT 2016


On Mon, Aug 1, 2016 at 4:41 PM, Anton Zhilin via swift-evolution <
swift-evolution at swift.org> wrote:

> Disclaimer: I have not (yet) prepared a proposal, or even something that
> could be considered a draft, but I want to hear public opinion on the topic.
>
> SE-0077 (about precedence groups) has been successfully implemented for
> Swift 3. (A thousand thanks to John McCall!) It suggests a model where we
> can prohibit certain operators from standing next to each other.
>
> This was intended to be the second part of that proposal. We now have to
> think if we should drop some precedence relationships between standard
> operators. Here are examples of parentheses dropping that can be ambiguous
> to reader:
>
> 1/3 as Double   // should we prohibit this?
>

Why should we? I would absolutely want that to work exactly as it does now
(0.333333...).

1 | 2 ^ 3   // or this?
>

No. Both of those are bitwise operations. They are often used together.
They have a refined relative precedence in Swift that makes sense.

a && b | c   // or this?
>

Now that's more interesting. Maybe?

Should we break standard precedence hierarchy and if yes, how?
> For those involved in the mentioned proposal, how exactly should standard
> precedence groups relate?
>
> _______________________________________________
> 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/20160801/a9245770/attachment.html>


More information about the swift-evolution mailing list