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 upChange integer fallback RFC to suggest `i32` instead of `int` as the fallback #452
Conversation
tbu-
added some commits
Nov 7, 2014
This comment has been minimized.
This comment has been minimized.
1fish2
commented on text/0212-restore-int-fallback.md in cd464e9
Nov 7, 2014
|
For this use, I suggest that |
This comment has been minimized.
This comment has been minimized.
|
As I don't want this PR to get filled with extra noise, I'll just say that there doesn't exist a 16-bit architecture Rust is targeting right now. |
This comment has been minimized.
This comment has been minimized.
1fish2
commented on text/0212-restore-int-fallback.md in cd464e9
Nov 7, 2014
|
Yes! In selecting the fallback type, we should rule out platform-dependent types due to portability bugs. We can rule out unsigned types because the values sometimes need to be signed. Rule out That leaves |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
Changing the fallback to |
This comment has been minimized.
This comment has been minimized.
thestinger
commented
Nov 8, 2014
|
@P1start: I don't understand why we would want redundant integer type... especially if it wasn't just an alias and forced the usage of casts. The |
This comment has been minimized.
This comment has been minimized.
|
What I mean is that there’s an advantage of having an integer type that is just ‘an’ integer type, and not any size in particular. (It could still be 32 bits, but that would not be much more than an implementation detail. There could be an attribute, for example, to change its size.) A lot of the time when people write It’s just an idea, really: having a redundant integer type is certainly a bit weird. I certainly don’t think |
This comment has been minimized.
This comment has been minimized.
arcto
commented
Nov 8, 2014
|
I think this discussion is deviating from the issue: should integer fallback go to the specific size I'm for having a specific size ( |
This comment has been minimized.
This comment has been minimized.
thestinger
commented
Nov 8, 2014
A hardware integer type with no particular size is not useful. The only suitable integer type in that case would be a big integer.
Hardware integer types are not "reasonable" for arithmetic. They are bounded, and using them correctly requires considering the overflow cases.
There aren't cases where the size doesn't matter beyond an integer being abused as a boolean. |
This comment has been minimized.
This comment has been minimized.
dobkeratops
commented
Nov 8, 2014
|
I think there's a lot of merit to making int "at least 32bits", many programmers expect it; even on 16bit machines, 32bit values were common... 16bit machines weren't limited to 64k ram,etc. There were/are also 16bit architectures that were basically logically 32bits, its just 16bit arithmetic happens to be faster. But you'd need another type which is 'definitely the pointer size' But imagine if you could select types at compile time: type MyInt = max<int,i32>; //std::whatever::min<A,B> is some builtin that selects the smallest int is whats used for indexing - but does associated types make it easier to get the desired index from the collection now? |
This comment has been minimized.
This comment has been minimized.
|
@thestinger I think the argument is about offering better type semantics for integer-sizedness. Define int/uint as a synonym for i32/u32 (move old int/uint to some other name), and promote them for programming "in the small" (where overflowing an i32 is rarely a concern-- especially if you're just using them as opaque values for some generic code), and as a way to advertise that the size of the number has not been seriously reflected on. Sort of like stubbing out types. |
This comment has been minimized.
This comment has been minimized.
It is not, for the reasons laid out in the RFC text: it is more correct for the cases where the fallback applies. You are free to open an RFC for the other cases (I would appreciate it), but please don't go offtopic here. |
This comment has been minimized.
This comment has been minimized.
|
+1, falling back to a concrete, clearly defined integer size seems to be less problematic than falling back to the systems pointer size. |
This comment has been minimized.
This comment has been minimized.
comex
commented
Nov 9, 2014
|
I'm not sure it's as off topic as you suggest. Shipping one without the other would, in my opinion, leave the language buggy: two cases that programmers would expect to produce a "generic integer type" (a number without context, and a type called |
This comment has been minimized.
This comment has been minimized.
|
@comex No matter whether |
This comment has been minimized.
This comment has been minimized.
|
+1. In my view, you shouldn't rely on integer fallback unless you are programming in the small, and I cannot foresee nobody programming in the small on a 16-bit architecture. Getting rid of |
pnkfelix
assigned
nrc
Nov 13, 2014
This comment has been minimized.
This comment has been minimized.
|
The PR seems to change the mode of text/0401-coercions.md, it probably shouldn't. |
This comment has been minimized.
This comment has been minimized.
|
@nick29581 Fixed. |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@nick29581 Since there's still no negative feedback, can I expect something to happen here? In my opinion we have a clear argument for this RFC (without negative responses!), yet it's still not merged. |
This comment has been minimized.
This comment has been minimized.
|
@tbu we (the Rust team) spent some time discussing this at the work week, we've got to do some more haggling over the details (aka, consensus building :-) ), expect news soon. |
This comment has been minimized.
This comment has been minimized.
Valloric
commented
Dec 15, 2014
|
This would be a great change. 32bit ints are faster than 64bit ints for all the reasons listed in the RFC changes, but just having the default int pinned down to a specific size and not having it architecture-dependent is a massive bonus to Rust's claim of aiming for robust code. Compiling code on two different architectures should not lead to hard-to-track-down bugs. |
This comment has been minimized.
This comment has been minimized.
|
See this post for more thoughts from the Rust team. I think this means I can merge this RFC, but I should double check first... |
This comment has been minimized.
This comment has been minimized.
|
At least conceptually, it should be merged, yes. I haven't read the exact text in a while. |
This comment has been minimized.
This comment has been minimized.
|
Merging, r=nikomatsakis |
nrc
added a commit
that referenced
this pull request
Dec 25, 2014
nrc
merged commit da7d52e
into
rust-lang:master
Dec 25, 2014
This comment has been minimized.
This comment has been minimized.
|
Since this modifies an existing RFC, there is no new tracking issue, instead we will continue to use issue 16968 |
tbu- commentedNov 7, 2014
Rich diff