-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Amend RFC 544: Use isize/usize
as the literal suffixes for themselves
#573
Conversation
Point of clarification: Can you clarify what the RFC is referring to when it says that "isz" and "usz" would become additional "reserved words"? We're about literal suffixes here, right? That does not require them to be keywords or otherwise reserved, as far as I know. |
+1 from me, unsurprisingly. |
I prefer the extremes: |
@nikomatsakis, I am under this impression because @cmr commented in #544:
|
@tshepang, some would find |
@nikomatsakis, and on second thought, I'll update this PR tonight (local time). |
@CloudiDust I took that to mean that all literal suffixes in general are reserved, meaning that it is invalid to put anything other than an existing suffix after a literal, making it possible to add new suffixes later without it being a breaking change. |
@rkjnsn, yeah this is also my understanding now. I forgot about |
I'll also note that I'd be fine with |
+1 for isz/usz |
👍 anything but |
@CloudiDust I didn't mean that suffixes in use needed to be reserved words, merely that all integer suffixes are already reserved. |
-1, too ugly |
@liigo, then what about |
+1 to @rkjnsn We probably want symmetry with the datatype themselves rather than introducing more names. |
To suggest a lightweight empirical approach: Step 1. Finish converting misuses of Step 2. Pick a frequency metric for these literal suffixes, e.g. the % of source files in the library where they appear. Or the % of non-blank, non-comment source lines in the library where they appear. Or the % of integer literals that use these suffixes. Pick high and low bounds, say, 30% and 70% of source files. Step 3. Grep the library to measure this frequency. If usage is below the low bound, then it's not worth documenting/teaching/remembering/searching/hassling shorthand terms like Step 4. If shorthand terms may be worth the costs, do a small experiment to see which of |
I did suggest ed isize/usize, in your original int/uint rename RFC, but you
|
@1fish2, this can be a fine method if time/resource permits. @liigo, eh, sorry it seems that you didn't comment about the But yes in #544, Now IMHO |
Also,
Eh, 42 is what? While |
Just a note - I'm feeling more and more comfortable with is/us as the days go by. |
-1 |
+1 for isz/usz |
-1 Not a fan of isz or usz because I hit s and z with the same finger and that's really disruptive. :( Edit: was looking at some of the other options proposed (when? dunno). Would totally be ok with uz/iz. I know it doesn't necessarily follow as an abbreviation, but I'm used to that (n as abbrev for "decimal," for example). |
How about the signed integer becoming just |
Using let val1: iz = 42;
let val2 = 42iz;
let val3: uz = 42;
let val4 = 42uz; |
( |
+1 for "isz" and "usz", because "sz" is a pretty clear abbreviation for "size", so they're clear and succinct in my opinion. But all the other alternatives are better than "is" and "us", in my opinion, which I can't help but read as the verb "is" and the abbreviation for microsecond, like a bunch of other people. |
Admitting another bikeshed, |
If this isn't done by Beta, will we be stuck with |
@tshepang, I am not sure. It seems to me that there are still a fair amount of breaking changes happening, so I'm wondering if the beta should be postponed or if an alpha2 is preferable to a beta1. No matter what the next release is called, if it is going out next week, then I don't expect "non-critical" breaking changes to cease. |
I feel the rush for Alpha (Jan 09) was rather frantic, where people made decisions with not enough discussion/feedback. I'd rather this be avoided in future, so I think next week's release should be another Alpha, not a Beta. |
An alternative is to support type ascription, then just use type ascription where necessary and get rid of numeric suffixes. |
@nick29581, yeah I just read that RFC and I prefer that now. Let's get rid of the suffixes. |
Funny that I was just thinking about making a comment here to suggest type ascription and Nick beat me to it. :) |
Argh, I dropped off this thread for a while. Sorry, lots of demands. I'd rather not replace suffixes with type ascription. For one thing, there are legitimate concerns raised on the type ascription thread about the desired syntax, and I don't know when it would be unfeature-gated precisely (though I think some form of type ascription is probably inevitable). In any case, it seems like needless backwards incompatibility and pain to remove suffixes. I've largely been persuaded that we should just use |
I don't have a strong preference here; |
As little as it comes up, I'm kinda with everyone else with regard to it
|
Thanks for the new timeline and I'll update this RFC to use @archer884, I think #803 is a better place for discussions about type ascription. Let's talk there. :) |
isz/usz
as the literal suffixes for isize/usize
isize/usize
as the literal suffixes for themselves
\0/ |
Just FYI, I started a branch implementing these changes in the background just to observe the effect. So far, all uses of |
The branch is here if you are curious: https://github.com/nikomatsakis/rust/tree/suffixes |
@nikomatsakis, thanks a lot. |
The core team has decided to accept this RFC. There have been lots of reasonable suggestions, but in the end going with the complete type name seems to be the most unambiguous -- inference ensures that writing out a |
Tracking issue: rust-lang/rust#22496 |
The literals 0is and 0us have been deprecated in favor of 0isize and 0usize. Reference: rust-lang/rfcs#573
This RFC (or RFC amendment) proposes that
isize/usize
get used as the literal suffixes for the typesisize/usize
, in order to address the problems of the previously chosenis/us
.This RFC used to promote
isz/usz
, which was brought up by @rkjnsn in this thread.Rendered View.
Note: the Rendered View shows the amended RFC 544, but the interesting parts are better highlighted in the diff.