Skip to content

Commit fe40a7f

Browse files
committed
Amend RFC 544: Propose isz/usz as the suffixes.
1 parent baf0ab3 commit fe40a7f

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

text/0544-rename-int-uint.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,42 @@ However, given the discussions about the previous revisions of this RFC, and the
4646

4747
# Detailed Design
4848

49-
- Rename `int/uint` to `isize/usize`, with `is/us` being their literal suffixes, respectively.
49+
- 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-
Some would prefer using `isize/usize` directly as literal suffixes here, as `is/us` are actual words and maybe a bit *too* pleasant to use. But on the other hand, `42isize` can be too long for others.
52+
There are different opinions about which literal suffixes to use. The following section would discuss the alternatives.
53+
54+
## Choosing literal suffixes:
55+
56+
### `isize/usize`:
57+
58+
* Pros: They are the same as the type names, very consistent with the rest of the integer primitives.
59+
* Cons: They are too long for some, and may stand out too much as suffixes.
60+
61+
### `is/us`:
62+
63+
* 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`:
67+
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.
70+
71+
### `iz/uz`:
72+
* 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`.
73+
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.)
5377

5478
`usize` in action:
5579

5680
```rust
5781
fn slice_or_fail<'b>(&'b self, from: &usize, to: &usize) -> &'b [T]
5882
```
5983

60-
See **Alternatives B to L** for the other alternatives that are rejected.
84+
See **Alternatives B to L** for the alternatives to `isize/usize` that have been rejected.
6185

6286
## Advantages of `isize/usize`:
6387

0 commit comments

Comments
 (0)