Skip to content

Commit c3e4beb

Browse files
committed
Various adjustments and discussions about i/u.
1 parent fe40a7f commit c3e4beb

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

text/0544-rename-int-uint.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ However, given the discussions about the previous revisions of this RFC, and the
4949
- Rename `int/uint` to `isize/usize`, with `isz/usz` being their literal suffixes, respectively.
5050
- Update code and documentation to use pointer-sized integers more narrowly for their intended purposes. Provide a deprecation period to carry out these updates.
5151

52+
`usize` in action:
53+
54+
```rust
55+
fn slice_or_fail<'b>(&'b self, from: &usize, to: &usize) -> &'b [T]
56+
```
57+
5258
There are different opinions about which literal suffixes to use. The following section would discuss the alternatives.
5359

5460
## Choosing literal suffixes:
@@ -61,27 +67,23 @@ There are different opinions about which literal suffixes to use. The following
6167
### `is/us`:
6268

6369
* Pros: They are succinct as suffixes.
64-
* Cons: They make an extra pair of reserved words which are actual English words, with `is` being a keyword in many programming languages and `us` being an abbreviation of "microsecond", which makes them confusing as suffixes, though technically there should be no ambiguities between "`is` the suffix" and "`is` the keyword with other use cases (in the future)". Also, `is/us` may be *too* short (shorter than `i64/u64`) and may be *too* pleasant to use, which can be a problem.
65-
66-
### `isz/usz`:
70+
* Cons: They are actual English words, with `is` being a keyword in many programming languages and `us` being an abbreviation of "unsigned" (losing information) or "microsecond" (misleading). Also, `is/us` may be *too* short (shorter than `i64/u64`) and *too* pleasant to use, which can be a problem.
6771

68-
* Pros: They are the middle grounds between `isize/usize` and `is/us`, neither too long nor too short, and they are not actual English words.
69-
* Cons: An extra pair of reserved words.
72+
Note: No matter which suffixes get chosen, it can be beneficial to reserve `is` as a keyword, but this is outside the scope of this RFC.
7073

7174
### `iz/uz`:
7275
* Pros and cons: Similar to those of `is/us`, except that `iz/uz` are not actual words, which is an additional advantage. However it may not be immediately clear that `iz/uz` are abbreviations of `isize/usize`.
7376

74-
This author believes that `isz/usz` are the best choices here.
75-
76-
(Note: Even if `is/us` don't get used as literal suffixes, it can be beneficial to reserve `is`, but this is outside the scope of this RFC.)
77+
### `i/u`:
78+
* Pros: They are very succinct.
79+
* Cons: They are *too* succinct and carry the "default integer types" connotation, which is undesirable.
7780

78-
`usize` in action:
81+
### `isz/usz`:
7982

80-
```rust
81-
fn slice_or_fail<'b>(&'b self, from: &usize, to: &usize) -> &'b [T]
82-
```
83+
* Pros: They are the middle grounds between `isize/usize` and `is/us`, neither too long nor too short. They are not actual English words and it's clear that they are short for `isize/usize`.
84+
* Cons: Not everyone likes the appearances of `isz/usz`, but this can be said about all the candidates.
8385

84-
See **Alternatives B to L** for the alternatives to `isize/usize` that have been rejected.
86+
Thus, this author believes that `isz/usz` are the best choices here.
8587

8688
## Advantages of `isize/usize`:
8789

@@ -90,6 +92,8 @@ See **Alternatives B to L** for the alternatives to `isize/usize` that have been
9092
- The names are newcomer friendly and have familiarity advantage over almost all other alternatives.
9193
- The names are easy on the eyes.
9294

95+
See **Alternatives B to L** for the alternatives to `isize/usize` that have been rejected.
96+
9397
# Drawbacks
9498

9599
## Drawbacks of the renaming in general:
@@ -106,7 +110,7 @@ Familiarity is a double edged sword here. `isize/usize` are chosen not because t
106110

107111
# Alternatives
108112

109-
## A. Keep the status quo.
113+
## A. Keep the status quo:
110114

111115
Which may hurt in the long run, especially when there is at least one (would-be?) high-profile language (which is Rust-inspired) taking the opposite stance of Rust.
112116

0 commit comments

Comments
 (0)