-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Guide: what to do about int #15526
Comments
I don't understand the issue. What decision needs to be made? |
Int vs some sort of size. Generally, int is not actually what you want. |
Do you know what the intended use of Machines with 64-bit pointers often have 64-bit arithmetic, in which using If I think the most sensible default to use would be |
On uses of Apparently the analogous type in C is used to store pointer offsets, which can be negative. See [1]. So is it safe to say that [1] https://stackoverflow.com/questions/1464174/size-t-vs-intptr-t |
From #16446:
Except for range or size-related values, the guide should use fixed-size integer examples (e.g. Variable bindings section), probably The guide should highlight the relation of |
rust-lang/rust-guidelines#24 proposes integer style guidelines. https://github.com/1fish2/Rust-rfcs/blob/int-index-for-portability/active/0000-intindex.md gives background on In short, Rust defines integer types |
What we decide here is going to have an impact on the interface to some of the libraries, such as Nominating; suggest 1.0 P-backcompat-libs. |
We should decide this, but not 1.0. |
@steveklabnik Just to clarify, is the question here about what to do when there isn't an inferred type for integer literals (which will be resolved by reinstating the fallback), or API design, or some other place where you're recommending a type? @pnkfelix I think that these API decisions can be made as part of the stabilization/guidelines process. |
The question is, right now I annotate every single literal with It currently looks like fallback is gonna eventually get accepted, so this |
I'm not sure this is a good idea. It breaks backwards compatibility if some interface changes from using |
@steveklabnik Just recently, I pointed a friend to the guide. He's a systems/embedded programmer (one of the reasons I suggested Rust), and the first thing he asked was what the size of Having a pointer sized integer isn't confusing. Even calling it
So, can we have a PR changing most of the |
@alexchandel I see the fallback type and the type we reccomend as being for general use as being one and the same. Why fall back to the non-default type? that makes no sense. I am on team 'fallback to i32.'
It's not worth doing until we make a conventions decision here. |
@alexchandel Unfortunately, many programmers don't fully read/grok/remember the docs. They'll make assumptions based on other languages. Thus calling it @steveklabnik I agree about fallback to |
@1fish2 I disagree, programmers have IQs above 42. And if someone is writing production code in Rust and they never learned what the base types are, then there's no helping them. But the name is changing, so it's moot. Indeed, the guide has been changed to use |
@alexchandel Just look at arbitrary Rust code on github. Most uses of |
Yes, this can be closed. |
@steveklabnik Excellent. Cheers! BTW, the Guide might want to say what Is there a doc on Rust's type inference? @alexchandel No disrespect intended for my fellow programmers. It's not about intelligence. It's about design complexity & usability, busy people, project time pressures, limited working memory, using many languages on a daily basis, and jumping to conclusions. To take one example, I've had fellow Google engineers not know about key Java facts like precise exceptions (which enables portability but severely limits code motion optimizations), which primitives are atomic in read/write, or how to write bounded generics. How many programmers have read the language spec of the languages they use? Back to Rust, there have been many uses of |
@alexchandel Yes, that was an extreme example. The point is it was a usability problem, not users' fault. Those weren't IQ 42 programmers surprised to learn via the Rust mailing list that |
Respect `#[allow(unused_braces)]` fix rust-lang#15526
I've been using
int
because its familiar, but it may not be the right thing to suggest. Can we get a decision here?The text was updated successfully, but these errors were encountered: