-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
proposal: math/bits: rename OnesCount
to Weight
(Go 1.9)
#20844
Comments
Sorry, it's almost certainly too late. Go 1.9 isn't out yet, so it's theoretically possible to change yet, but Go 1.9 is basically done at this point. You missed the big naming thread in #18616 where nobody mentioned "weight". |
Further, most of the @golang/proposal-review group is about to go on summer vacations, so there might not be a proposal review meeting before Go 1.9 ships. /cc @griesemer @brtzsnr @cespare @cherrymui @josharian @dr2chase @randall77 |
Thank you @bradfitz for your response. I'm following the Go development by looking at what's new in the betas every now and then. I missed that big naming thread indeed. |
The OnesCountX functions parenthetically mention that the operations is also known as population count, as there are many sources that refer to the operation as such. I could see the value in adding this to the docs as another also-known-as. I don't recall coming across this name for the concept, personally, so I can't say how common it is. (Fair disclosure: I don't mess with bits that often and it's been a while since I did any readings in the information theory literature so I could just be forgetting that I've seen this). |
Ok @jimmyfrasche, if you consider mentioning the A.K.A. in the docs, you may find this Wikipedia article useful: https://en.wikipedia.org/wiki/Hamming_weight Considering other names (most notably But when you have a In closing, I'm actually glad that you finally chose |
(Responding to my own musing about the suitability of ... because where there's a |
Too late. There was a long discussion about naming in #18616 and it's done. Even if you came up with a spectacularly better name, it's done. And bits.Weight is not spectacularly better than bits.OnesCount anyway. OnesCount is much clearer to people without information-theory backgrounds, and that's the vast majority of our developer base. |
Hi, this is my first proposed change to Go. I hope I'm not missing anything, and, more importantly, that I'm not coming too late in the Go 1.9 release cycle.
May I please suggest renaming
bits.OnesCount
tobits.Weight
?Besides the name
bits.Weight
being shorter and along the lines ofbits.Length
, it's also the proper information-theoretic jargon -- the Hamming weight, or the bit weight.Moreover, it is possible to extend this terminology to other measures as well. It needs not be done in the standard library if user code is better suited for this; but it will be semantically easy (and once again consistent with the information theory textbook) to add, for example, the distance (i.e. the Hamming distance) as follows:
The text was updated successfully, but these errors were encountered: