New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/gc: int should be 64 bits wide on 64-bit platforms #2188
Labels
Milestone
Comments
Comment 4 by jp@webmaster.ms: I did not mean to make int longer. Somebody changed the subject line. I talked about arrays only. Currently, make() and [] accept ANY integral type without explicit conversion to int: a := make([]int32, byte(2)) println(a[byte(1)]) Can they deal appropriately with integrals longer than int (uint32,int64,uint64) ? a := make([]int8, uint64(1<<32+2)) println(a[uint64(1<<32)]) |
Comment 6 by webmaster@webmaster.ms: len() can have a "fuzzy" integral type, similar to parameter of make() In "len(a) + int(1)" it is int. In "len(a) < byte(1)" it is byte. In "println(len(a))" or "x := len(a)" it is uintptr. It is also similar to the type of numeric constant (they can be used as any integral type without explicit conversion) but with defaulting to uintptr instead of int. |
Comment 7 by webmaster@webmaster.ms: I understand from the maillist, you insist on len() to be int only to have ability to write "for i:=0; i<len(x); i++". This will be possible. As well as "for i:=uint64(0); i<len(x); i++" for long arrays. |
Comment 8 by webmaster@webmaster.ms: I understand from the maillist, you insist on len() to be int only to have ability to write "for i:=0; i<len(x); i++". This will be possible. As well as "for i:=uint64(0); i<len(x); i++" for long arrays. But this will fail (size is uintptr, i is int: size:=len(x) for i:=0; i<size; i++ |
Discussing language changes in the issue tracker is not particularly productive. If you'd like to continue this conversation please reply to that thread in golang-nuts. But please also read it first. The problem with a fuzzy len is that if you write for i := 0; i < len(x); i++ { and i has type int but len(x) is some fuzzy number that is bigger than any possible int, then the loop will be wrong: it will wrap around and die using i as a (negative) loop index. |
There have been lots of recent relevant commits. hg log -k 'Update issue #2188' :-( |
What is the use of "update issue #2188" if they don't show up here? |
This issue was closed by revision 10ea651. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by webmaster@webmaster.ms:
The text was updated successfully, but these errors were encountered: