Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upPrecedence of `box` is possibly wrong #21192
Comments
nikomatsakis
added
the
I-nominated
label
Jan 15, 2015
huonw
added
the
A-grammar
label
Jan 15, 2015
This comment has been minimized.
This comment has been minimized.
|
cc @pnkfelix |
brson
added this to the 1.0 beta milestone
Jan 15, 2015
brson
added
P-backcompat-lang
and removed
I-nominated
labels
Jan 15, 2015
This comment has been minimized.
This comment has been minimized.
|
(subtask of #11779 ) ((well, sort of; depends on your definition of what "placement box" covers.)) |
nikomatsakis
referenced this issue
Jan 16, 2015
Closed
Fix precedence of '..' range notation and some grammar inconsistencies. #20958
nikomatsakis
assigned
pnkfelix
Feb 4, 2015
This comment has been minimized.
This comment has been minimized.
|
Assigning this to @pnkfelix too. |
This comment has been minimized.
This comment has been minimized.
|
It would be great if the language would require explicit () in cases like this, for us mortal programmers who have to read code. See this classic: http://lwn.net/Articles/382024/ |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@pnkfelix yes, this is making me change my mind. Even though my intution is that the precedence of |
This comment has been minimized.
This comment has been minimized.
|
still, could |
This comment has been minimized.
This comment has been minimized.
|
@pnkfelix I think this doesn't work because the precedence of fn main() {
println!("{}", 3_u32 + 4_u64 as u32);
}(Note also that my intuition is based on some notion that I think the precedence right now is roughly:
|
This comment has been minimized.
This comment has been minimized.
|
But, I-needs-decision! |
pnkfelix
added
the
I-needs-decision
label
Mar 26, 2015
pnkfelix
removed this from the 1.0 beta milestone
Mar 26, 2015
This comment has been minimized.
This comment has been minimized.
|
triage: P-medium |
rust-highfive
added
P-medium
and removed
P-backcompat-lang
labels
Apr 23, 2015
This comment has been minimized.
This comment has been minimized.
nixpulvis
commented
Feb 11, 2016
|
I agree, just bumped into this. let v = vec![1,2,3];
let x = box v[0];
let y = (box v)[0]; |
nikomatsakis
referenced this issue
Aug 7, 2016
Merged
Implement `impl Trait` in return type position by anonymization. #35091
brson
added
the
T-lang
label
Aug 25, 2016
nikomatsakis
referenced this issue
Aug 25, 2016
Closed
`box` and `in` expressions (tracking issue for RFC 809) #22181
This comment has been minimized.
This comment has been minimized.
|
triage: P-low Decided to keep this open as the place to discuss precedence of |
rust-highfive
removed
I-needs-decision
P-medium
labels
Aug 25, 2016
rust-highfive
added
the
P-low
label
Aug 25, 2016
This comment has been minimized.
This comment has been minimized.
nixpulvis
commented
Aug 25, 2016
|
@kjpgit I'm not sure I completely agree, although I do think Rust is airing in the side of too many levels now. As a programmer that primarily learned using Racket I'd love to throw parenthesis everywhere, but I really don't want to end up with a weird rule like you sometime need parens unless it's a box that is near other operators. I've always thought that precedence should be a programmer problem solved by education. Personally I've always wanted to see what an editor aware of the grammar of a language could do in terms of alerting programmers to potential issues. A simple fix with an editor would be to show the implicit parens at like 50% opacity. |
Mark-Simulacrum
added
the
C-bug
label
Jul 22, 2017
This comment has been minimized.
This comment has been minimized.
|
Triage: IIRC, we're going back the drawing board again with the box syntax stuff. @pnkfelix ? |
This comment has been minimized.
This comment has been minimized.
nixpulvis
commented
Sep 24, 2018
•
|
If you're going back to the drawing board. What's wrong with |
This comment has been minimized.
This comment has been minimized.
|
cc @rust-lang/wg-grammar : this remains an open question and it would be great to try to attack it. (It may well tie in with whatever syntax we adopt for |
nikomatsakis commentedJan 15, 2015
Now that
boxis a keyword, and not the~operator, I think it's precedence is wrong. It maintains the precedence of a symbolic unary operator but I think keyword unary operators should have lower precedence.In practical terms, this means that I think:
should parse as
and not
Nominating.