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

Can => be put even lower in operator precedence? #12875

Closed
IainNZ opened this issue Aug 30, 2015 · 4 comments
Closed

Can => be put even lower in operator precedence? #12875

IainNZ opened this issue Aug 30, 2015 · 4 comments
Labels
won't change Indicates that work won't continue on an issue or pull request

Comments

@IainNZ
Copy link
Member

IainNZ commented Aug 30, 2015

Just got caught out by combining => with ? :, e.g.

julia> Dict(1 => true ? println("foo") : println("bar"))
ERROR: TypeError: non-boolean (Pair{Int64,Bool}) used in boolean context

Except the situation I was in was

julia> x = Dict(:foo => 2)
Dict{Symbol,Int64} with 1 entry:
  :foo => 2

julia> Dict(:fizz => 1 == 1 ? x[:foo] : x[:bar])
ERROR: KeyError: bar not found
 in getindex at dict.jl:718

Which was very confusing, as I was wondering why would it be evaluating x[:bar]

@rened
Copy link
Member

rened commented Aug 31, 2015

The precedence was recently increased (#12285), actually. See also Jeff's comment: #12285 (comment)

I'd also like to see it more on the level of =, that's what the => feels most like for me.

@IainNZ
Copy link
Member Author

IainNZ commented Aug 31, 2015

Ah I see, essentially the same as what you said! Agreed that it feels like it should be at the level of =, its got almost the same semantics except I guess in that one case that @JeffBezanson was showing with the in thing. I guess this is a wont-fix then :(

@IainNZ IainNZ added the won't change Indicates that work won't continue on an issue or pull request label Aug 31, 2015
@IainNZ IainNZ closed this as completed Aug 31, 2015
@rened
Copy link
Member

rened commented Sep 4, 2015

@IainNZ - just to make sure you see the ongoing discussion on #12285 (comment), perhaps this is not a "won't fix" any more

@IainNZ
Copy link
Member Author

IainNZ commented Sep 4, 2015

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
won't change Indicates that work won't continue on an issue or pull request
Projects
None yet
Development

No branches or pull requests

2 participants