Hacker News new | ask | show | jobs
by WakiMiko 2764 days ago
Rust has a `usize` which is 32 or 64 bits depending on the platform and also serves as the native index type for arrays and such.
1 comments

Yeah, that makes sense because you need some type to span the address space and that depends on the size of the address space. That is what int is used for in go, though why they chose signed rather than unsigned is confusing. unsigned you would never have to do negative bounds checks and you can prove a lot of other useful things if you know your index is always positive.
I don't know how go does it, but in some languages negative indices count backwards from the rear end. E.G. myarr[-1] == myarr[myarr.length-1].