News for hackers. Stuff that matters.
Re:Go 2, here we come by WakiMiko on Thursday November 29, 2018 @03:25PM (#18563628)
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.
Re:Go 2, here we come by friday99 on Thursday November 29, 2018 @05:17PM (#18564657)
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.
Re:Go 2, here we come by earenndil on Thursday November 29, 2018 @05:50PM (#18564902)
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].