@theme, my point about ssize_t is that, I always assumed that it is for storing “index offsets for containers”, but actually the standard doesn’t agree with me. I was misguided by the tutorials I read. So, we should prevent the same thing from happening to Rust. (I was actually making this point clear to the OP, not arguing with you, sorry for the confusion.)
But I don’t agree with the names idiff/usize. As the OP said:
“Ultimately, pointer-sized integers are used for many purposes (indices, sizes, offsets, pointers), and we don’t want to favor one of those uses over the others in the name.”
I agree with that. And idiff/usize is too specific.
The only semantic meaning of int/uint in Rust is that they are pointer-sized. Just like i32/u32 are 32bit-sized. But they are different from intptr_t/uintptr_t in that they are not only used for “intergers casted from pointers”.
imem/umem are better in this regard, they mean “integers for memory-related things”, but not too specific.
Still they are not ideal because some would think that “int memory”/“unsigned int memory” don’t seem right and don’t look like integer types at all. Personally I don’t find this a problem, but still …
Inspired by @liigo, I now think intx/uintx are better than imem/umem.
Because:
- It is clear that they are integer types.
- They are consistent with the other interger types in that they follow the signed-ness + size pattern.
-
x signifies the fact that their exact size is in a sense “unknown” or “varies”, or, platform-dependent.
- for better or worse,
intx/uintx somewhat look like index/uindex.
- Newcomers will ask the question: “why is there an
x?” And they’ll actually read the manual.