-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Restore int fallback #16968
Comments
Is there a reason why |
+1 on @vks' comment. |
I'm in favor of |
I think (Personally, I've never wanted to use |
C / C++ implementations use |
Seems right to use |
@vks I think |
@alexchandel Unfortunately this is not what the documentation teaches or uses. It does not even mention how I think even small programs should not use |
About the |
@vks I don't like the idea of granting a special place in the language to a particular fixed-size type. Also I run into i32 overflow pretty often, so I prefer i64. The fallback int is for prototyping only, and should be as large as possible without significantly compromising speed (like an emulated 32-bit on a 16-bit microcontroller, or an emulated 128-bit on a cpu with only 64-bit registers and operations), so it should be target dependent. @l0kod I think |
It does significantly compromise speed. It's up to 2x as slow as 32-bit integers on x86_64, on average in the range of 20-30% slower. |
Rust doesn't support an environment where the address space and largest possible size are not equal. It would require a lot of work and widespread movement away from a unified |
@thestinger I disagree, 20-30% slower integer operations is fine for prototyping. If you examine disassembled Rust on x86-64 OS X, you find that most of the operations are qword-sized already. Not to mention the fact that |
The |
In almost all of those example you rather want to (or even have to) use
The manual does not say how they are intended to be used.
If you prefer
Anyway, I don't really care which one will be the default, as long as it is not
It is virtually a default, given the way |
That's right. Moreover, one-letter suffixes like |
An existing problem isn't a sane rationale to create more problems. |
@thestinger What are you referring to with "more problems"? |
Restoring it as the fallback type when inference fails. |
I've assigned this to myself but I'm still working on automation and installation for now so would not mind if somebody else took it. |
Is there still agreement on that this is a good idea? It was an RFC that was merged pretty quick (within 7 days) – and afterwards discussions seemed to resolve in that |
Adding to that, if this ships with the 1.0 release, one can basically never go back, so it'd be best if the counter-points were addressed (which weren't addressed in the RFC), namely that (It only talks about "missing bugs". However the same could be said about C code that, unless it's specifically targeted by attackers, usually does not expose bugs.) |
I think the "no bugs yet" argument is not a good one, because at the moment most Rust developers are using x86-64. Portability bugs will arise when Rust gets widespread use on differing platforms. Arguably #16755 is a portability bug in the standard library as of today. |
After reading through both comment threads I think I agree that while at first glance it sounds like a reasonable modification it seems to have the potential of becoming a bad default in certain cases. And it's not like the lack of fallback is that painful to work with, the compiler messages are generally very explicit and the suffixes are not generally very intrusive. I mean, if you consider the examples in the RFC: let mut m = HashMap::new();
m.insert(1, 2);
m.insert(3, 4);
assert_eq(m.find(&3).map(|&i| i).unwrap(), 4); In today's rust would be: let mut m = HashMap::new();
m.insert(1i, 2i);
m.insert(3, 4);
assert_eq(m.find(&3).map(|&i| i).unwrap(), 4); And for _ in range(0, 10) {
} Becomes for _ in range(0u, 10) {
} The RFC states that it might deter newcomers but I think it's a moot point because if they come from C/C++ they still save massively on having to specify all the types and if they come from dynamically typed languages it might give them the false impression that those counter values have no type or are dynamically typed or that their type does not matter, which isn't strictly true in all the cases. |
Note that in both examples, there's no reason to make the integers variable-width (except for that |
Note that since RFC PR #452 has been accepted, the fallback is to |
Doesn't yet converge on a fixed point, but generally works. A better algorithm will come with the implementation of default type parameter fallback. If inference fails to determine an exact integral or floating point type, it will set the type to i32 or f64, respectively. Closes #16968
Doesn't yet converge on a fixed point, but generally works. A better algorithm will come with the implementation of default type parameter fallback. If inference fails to determine an exact integral or floating point type, it will set the type to i32 or f64, respectively. Closes #16968
Doesn't yet converge on a fixed point, but generally works. A better algorithm will come with the implementation of default type parameter fallback. If inference fails to determine an exact integral or floating point type, it will set the type to i32 or f64, respectively. Closes #16968
fix: silence mismatches involving unresolved projections fix rust-lang#16801
fix: silence mismatches involving unresolved projections fix rust-lang#16801
rust-lang/rfcs#212
The text was updated successfully, but these errors were encountered: