Use a more clear suffix for isize and usize literals (isz and usz?)

When int and uint got renamed to isize and usize (yay!), the respective literal suffixes were renamed to is and us. However, the meaning of these suffixes is less than self-evident, and even knowing them, I find that it takes my brain a moment to assign them the correct meaning when reading code. A single ‘s’ isn’t really enough to evoke ‘size’, and this is exacerbated by the fact that ‘is’ and ‘us’ have other, more common meanings that must first be considered and ruled out. Both are English words, and 42us could additionally be interpreted as “42 microseconds”, or even just “42 unsigned”, which loses some meaning. While it as likely that I’ll get more used to seeing is and us as indicating isize and usize over time, I think it is worth discussing and considering a couple of alternatives.

The most clear suffixes would be isize and usize. This matches the convention set by the fixed-size integer types of having the type name match the suffix, and doesn’t leave any room for misinterpretation. A few people on the renaming RFC suggesting starting with these and only shortening them if they turned out to be too unergonomic.

If we do want shortened suffixes, I would propose using isz and usz. These are the same length as most of the fixed-size suffixes, and are much better at evoking isize and usize. They also don’t suffer from the problem of having overloaded meanings.

If we had to go with a two character suffix, I would even prefer iz and uz over is and us, which, while less clear than the above options, still seems more so than the status quo. It at least avoids some of the meaning overload, lessening the mental burden.

4 Likes

isz/usz are nice choices, not too long nor too short.

I don’t find isize/usize too long, but I can see why some would think so, and is/us are a little too pleasant to use in my eyes.

3 Likes

Filed as RFC PR 573.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.