Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate precedence of & and |. for #5187 #25322

Closed
wants to merge 1 commit into from
Closed

Conversation

JeffBezanson
Copy link
Member

This will allow us to change the precedence of these operators.

This change is certainly unnatural for bit twiddling; writing x & mask == 0 you definitely expect & to happen first. We do more bit masking in Base than I expected.

What should we do about ? Here it still has + precedence, but it seems a bit odd for it to have wildly different precedence than & and |.

@JeffBezanson JeffBezanson added deprecation This change introduces or involves a deprecation parser Language parsing and surface syntax labels Dec 29, 2017
@vtjnash
Copy link
Member

vtjnash commented Dec 29, 2017

What should we do about...

It seems this PR partially also introduces support for detecting "ambiguous precedence"? I think I'm vaguely in favor of just requiring parens around some of the other combinations of operations (I'm mainly thinking of combinations of bitwise and arithmetic operators here, like a + b << c).

@Sacha0
Copy link
Member

Sacha0 commented Dec 29, 2017

One of the things that #25180 taught me is that defensive parens seem the rule rather than the exception, so I am vaguely with @vtjnash :).

@JeffBezanson
Copy link
Member Author

Yes, after this experience I agree we should have ambiguous precedence errors and maybe some cases of non-transitive precedence.

@ararslan
Copy link
Member

Precedence change aside, I just want to point out how much clearer I think the code looks with parentheses for these operations. 👍

@JeffBezanson JeffBezanson added the triage This should be discussed on a triage call label Jan 4, 2018
@JeffBezanson
Copy link
Member Author

Triage prefers .&& and .|| for the original desired application of this, which can be added later non-breaking.

We also would like to have ambiguous precedence errors at some point in the future, but it seems a bit half-assed to only add this for & and | right now. Can be added during 1.x by having the warnings off by default and opt-in until 2.0.

@JeffBezanson JeffBezanson removed the triage This should be discussed on a triage call label Jan 4, 2018
@ararslan ararslan deleted the jb/bitops branch January 4, 2018 21:10
@fredrikekre
Copy link
Member

The added parenthesis helps with visual parsing IMO, worth merging that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation This change introduces or involves a deprecation parser Language parsing and surface syntax
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants