-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
RFC: move =>
to precedence level of |>
#12285
Conversation
makes sense. while |
👍 |
Wouldn't similar arguments apply to |
If you think of an arrow as "implies", then it makes sense for it to be lower than |
RFC: move `=>` to precedence level of `|>`
This breaks some packages' uses of FactCheck, hopefully all fixable with enough parentheses. I strongly encourage anyone who cares about the health of the package ecosystem leading up to 0.4 to install Vagrant and do some local PackageEvaluator runs while Iain's system is out of commission. |
precedence of `in` vs `=>` changed in JuliaLang/julia#12285
precedence of `in` vs `=>` changed in JuliaLang/julia#12285 parens in test/model.jl and sdp I should be running this locally but I'm not, can squash when done missed a comparison in sdp
Kind of funny, this is probably the only really breaking change that seems to have happened in the last couple of weeks, just because of the FactCheck thing. Its not too many packages though, and an easy enough thing to fix. |
precedence of `in` vs `=>` changed in JuliaLang/julia#12285 parens in test/model.jl and sdp I should be running this locally but I'm not, can squash when done missed a comparison in sdp
This gets around precedence issues of `=>` due to JuliaLang/julia#12285 closes #51
This gets around precedence issues of `=>` due to JuliaLang/julia#12285 closes #51
This gets around precedence issues of `=>` due to JuliaLang/julia#12285 closes #51
I have to say I rarely use the Dict(:key => a == 1, :key2 => b == "hi" || b == "hey") The precedence change makes it fail now: Dict(:key => a == 1)
# equals
Dict(=>(:key, a) == 1)
# equals
Dict(false) (sidenote, this currently throws a BoundsError, see #12451) Of course, the following works but I always feel an itch to remove the "unnecessary" parens: Dict(:key => (a == 1), :key2 => (b == "hi" || b == "hey")) Personally, I'd prefer to see the behavior reverted to what is was before this commit, as I believe it is more widely used. |
I really don't agree. I don't think using the result of a comparison as a
key or value is that important. In most cases comparisons need parens to be
used for their value, e.g. (a==b)+1.
|
I don't have strong feeling either way, but I can't find any |
This breaks the precedence of the Notably this is inconsistent with other languages
|
Yeah, I have to admit this change has not grown on me. |
@mdcfrancis Could you be more specific about "inconsistent with other languages"? Which ones? |
@nalimilan - that's a JavaScript snippet. |
I don't think I've ever used ( :a=>1 ) in Dict( :a=>2 ) as I would commonly be checking based on the key and would use haskey. It is rare that I would be checking for value equality as well. |
I also think this was a step backwards. Other languages? Well, ':' is not an operator in other languages, but the way |
Ok I see the case for reverting this. I'm not sure we want to add a new precedence level between |
I think you really should though, for this, so that assignment of a Pair is handled well, unless you feel that that people really need to use () around the pair.
|
The |
Yes, in those examples, it works out fine, but I do think it's better to have it explicitly higher precedence than assignment, as it isn't really an assignment. |
Well there are already about 16 of them, and it's pretty confusing. Also if it has strictly higher precedence then |
OK, so you'd just add it to the assignment precedence list in |
For now I'm just going to revert this. I also realized that |
Thanks Jeff, much appreciated. |
Sorry to reopen this topic, but something seems to be wrong with => precedence in 0.4-rc1 and 0.5. Observe (from rc1): julia> d = Dict(1=>2,3=>4) julia> 1=>2,3=>4 The second result is certainly unexpected, especially given the first result |
Yeah well, too late now. |
Is the problem here really the parsing of |
The precedence of Implication is the lowest precedence logical operator, so the arrows (which are not much used, so not a huge deal so far) should really be moved below |
The most noticeable thing the |
Which precedence change broke FactCheck: the original change or the more recent revert of it? |
The original one. So it should be safe now to go back on that deprecation where FactCheck went from edit: also possible that the improvements to Base.Test will make FactCheck less necessary |
We should be ok; |
Before:
after:
My reasoning is that the precedence of
=>
needs to be higher thanin
or==
, but lower than+
. It should also be lower than:
, since you can't make ranges of Pairs. That puts it directly in the precedence level of|>
, which also makes sense since|>
and=>
look vaguely similar.