News for hackers. Stuff that matters.
Re:Go 2, here we come by Sharlin on Thursday November 29, 2018 @02:57PM (#18563382)
It may be crazy but it's not exactly without precedent. Neither C nor C++ fix the sizes of the fundamental integer types, although for backward-compatibility reasons popular 64-bit platforms still have 32-bit `int` and even `long`. But yeah, there's a reason eg. Rust has no `int` and friends but `i32` etc. instead.
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].
Re:Go 2, here we come by lemoncucumber on Thursday November 29, 2018 @03:42PM (#18563794)
Right, 64-bit Windows has 32-bit int and long and 64-bit long long (LLP64) while 64-bit unixes generally have 32-bit int and 64-bit long/long long (LP64).
Re:Go 2, here we come by user5994461 on Thursday November 29, 2018 @03:13PM (#18563513)
C only defines char, short, int has having a minimum size of 8, 16 and 32 bits.
Re:Go 2, here we come by mrb on Thursday November 29, 2018 @03:17PM (#18563550)
Actually C defines the minimum size of "int" as 16 bits, because it defines the minimum range it should support as [-32768 .. 32767]

See https://en.wikipedia.org/wiki/C_data_types

Re:Go 2, here we come by shric on Thursday November 29, 2018 @04:52PM (#18564439)
Nit: [-32767 .. 32767] C permits ones' complement and sign-and-magnitude as well as two's complement.
Re:Go 2, here we come by jstimpfle on Thursday November 29, 2018 @03:21PM (#18563591)
no, int is 16 bits minimum