4 ms·
Ok, apparently my message wasn't clear. (It was written on the mobile phone, so it was too brief.) In practice, only when you're writing some loops with small
by przemoc 14y ago
Ok, apparently my message wasn't clear. (It was written on the mobile phone, so it was too brief.)
In practice, only when you're writing some loops with small number of iterations etc., you don't care whether your counter for instance is 24-bit integer or 48-bit, because 16-bit or maybe even 8-bit would be enough. In most other cases you care whether 64-bit value will fit into your value or not and whether it can be there at all. And if you care about memory you use smaller ints in your structures when bigger ones aren't needed.
So, to some extent, it is indeed not a big deal. But it still isn't "not an issue". We gain more than 2^31-1 elements in slices on 64-bit platforms, true, but it should be possible from the beginning, without need to redefine int on such platforms.
> Previous Go implementations made int and uint 32 bits on all systems.
> Among other things, this enables the allocation of slices with more than 2 billion elements on 64-bit platforms.
If they truly wanted to have platform-dependent int, then why 64-bit int on 64-bit platforms wasn't introduced from day 0? It's a valid question, because it would avoid this big (implementation) change at all.
> However, programs that contain implicit assumptions that int is only 32 bits may change behavior.
I can agree that this assumption is wrong, but why changing int implementation now?
> Due to the change of the int to 64 bits and some other changes, the arrangement of function arguments on the stack has changed in the gc tool chain. Functions written in assembly will need to be revised at least to adjust frame pointer offsets.
My main point is that variable-sized int implementation and usage gives more problems than we get profits in return, even more when previous and widely used 1.0 version, which 1.1 is going to be backward-compatible with, did it differently.
Again, I wouldn't comment if variable-sized int was in Go 1.0 implementation, but it wasn't.
- mseepgood 14y ago> Again, I wouldn't comment if variable-sized int was in Go 1.0 implementation, but it wasn't. It has always been in the Go 1.0 specification: "There is also a set of predeclared numeric types with implementation-specific sizes: uint either 32 or 64 bits int same size as uint" http://golang.org/ref/spec#Numeric_types http://golang.org/ref/spec#Numeric_types It's just that the Go 1.1 implementation now takes advantage of this freedom.
- enneff 14y ago> If they truly wanted to have platform-dependent int, then why 64-bit int on 64-bit platforms wasn't introduced from day 0? It's a valid question, because it would avoid this big (implementation) change at all. Because we have finite time, and it was easier to implement at the time. This property has been in the language spec since day 1. It should not come as a surprise to anyone. How much of my hundreds of thousands of lines of Go code have I needed to change because of this implementation change? None.