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 upGuide: what to do about int #15526
Comments
steveklabnik
added
the
A-docs
label
Jul 8, 2014
This comment has been minimized.
This comment has been minimized.
|
I don't understand the issue. What decision needs to be made? |
This comment has been minimized.
This comment has been minimized.
|
Int vs some sort of size. Generally, int is not actually what you want. |
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
1fish2
commented
Aug 14, 2014
|
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 |
Gankro
referenced this issue
Aug 25, 2014
Closed
Bitv uses architecture-sized uints for backing storage #16736
This comment has been minimized.
This comment has been minimized.
|
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. |
pnkfelix
added
the
I-nominated
label
Sep 1, 2014
l0kod
referenced this issue
Sep 3, 2014
Merged
Restore int/f64 fallback for unconstrained literals #212
brson
added
the
P-high
label
Sep 4, 2014
This comment has been minimized.
This comment has been minimized.
|
We should decide this, but not 1.0. |
This comment has been minimized.
This comment has been minimized.
|
@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. |
alexcrichton
removed
the
I-nominated
label
Sep 4, 2014
This comment has been minimized.
This comment has been minimized.
|
The question is, right now I annotate every single literal with It currently looks like fallback is gonna eventually get accepted, so this |
This comment has been minimized.
This comment has been minimized.
I'm not sure this is a good idea. It breaks backwards compatibility if some interface changes from using |
This comment has been minimized.
This comment has been minimized.
alexchandel
commented
Nov 5, 2014
|
@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 |
This comment has been minimized.
This comment has been minimized.
|
@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. |
This comment has been minimized.
This comment has been minimized.
1fish2
commented
Nov 5, 2014
@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 |
This comment has been minimized.
This comment has been minimized.
alexchandel
commented
Jan 6, 2015
@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 |
This comment has been minimized.
This comment has been minimized.
|
@alexchandel Just look at arbitrary Rust code on github. Most uses of |
This comment has been minimized.
This comment has been minimized.
|
Yes, this can be closed. |
steveklabnik
closed this
Jan 6, 2015
This comment has been minimized.
This comment has been minimized.
1fish2
commented
Jan 6, 2015
|
@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 |
This comment has been minimized.
This comment has been minimized.
alexchandel
commented
Jan 16, 2015
This comment has been minimized.
This comment has been minimized.
1fish2
commented
Jan 16, 2015
|
@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 |
steveklabnik commentedJul 8, 2014
I've been using
intbecause its familiar, but it may not be the right thing to suggest. Can we get a decision here?