[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: new module 'popcount'
From: |
Matthew Woehlke |
Subject: |
Re: new module 'popcount' |
Date: |
Tue, 24 Jul 2007 12:45:16 -0500 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.12) Gecko/20070509 Thunderbird/1.5.0.12 Mnenhy/0.7.4.0 |
Ben Pfaff wrote:
The name 'popcount' is not perfect, but it is a well-known name
for this function. That is what it is called by, e.g., GCC,
Wikipedia, and _Hacker's Delight_.
Actually Wikipedia "popcount" and "population count" redirect to
"Hamming weight" :-).
I don't see why anyone would have trouble understanding
population count, unless an opaque, uncommented implementation
made it necessary to reverse-engineer the calculation.
My first reaction to "popcount" is 'something to do with stacks'. My
first reaction to "population count" is 'ytf do we have census code in
gnulib?!'.
My first reaction to "Hamming weight" is 'hmm, sounds familiar and
useful, like something with a legitimate place in gnulib'.
Obviously I'm not very familiar with use of such a function, but should
that be relevant? The name "popcount" is only meaningful if you already
are familiar with the function, otherwise it leaves you wondering what
it is and why it's in gnulib. The name "Hamming weight" seems more
likely to be recognized, if only in the 'feels like I heard about that
once' sense, by average programmers.
I do agree that 'hamming_weight' is a precise name for this
function. But it is not a descriptive name: one must know by
rote what a Hamming weight is. I think that "population count"
is far more logical.
I probably learned what a "Hamming weight" was at some point (sure seems
like I did, anyway). However, I can't say I'd ever heard of "population
count" until this thread. Therefore I think the above argument is
invalid, "population count" is no less obscure than "Hamming weight" in
my opinion (i.e. I would say "one must know by rote" about both).
Here's another exercise: ;-)
http://www.google.com/search?hl=en&q=%22population+count%22&btnG=Search
http://www.google.com/search?hl=en&q=%22hamming+weight%22&btnG=Search
I would have to say that gcc using the name is the biggest (and possibly
only) argument for "popcount".
--
Matthew
This .sig is false