Re: popcount - Mailing list pgsql-hackers

From Robert Haas
Subject Re: popcount
Date
Msg-id CA+Tgmoa18D-8FvtBE3-dJHDTX6A33OeAmRKa6R7+i8-E_o1G-w@mail.gmail.com
Whole thread Raw
In response to Re: popcount  (Peter Eisentraut <peter.eisentraut@enterprisedb.com>)
Responses Re: popcount  (David Fetter <david@fetter.org>)
List pgsql-hackers
On Tue, Jan 19, 2021 at 3:06 AM Peter Eisentraut
<peter.eisentraut@enterprisedb.com> wrote:
> On 2021-01-18 16:34, Tom Lane wrote:
> > Peter Eisentraut <peter.eisentraut@enterprisedb.com> writes:
> >> [ assorted nits ]
> >
> > At the level of bikeshedding ... I quite dislike using the name "popcount"
> > for these functions.  I'm aware that some C compilers provide primitives
> > of that name, but I wouldn't expect a SQL programmer to know that;
> > without that context the name seems pretty random and unintuitive.
> > Moreover, it invites confusion with SQL's use of "pop" to abbreviate
> > "population" in the statistical aggregates, such as var_pop().
>
> I was thinking about that too, but according to
> <https://en.wikipedia.org/wiki/Hamming_weight>, popcount is an accepted
> high-level term, with "pop" also standing for "population".

Yeah, I am not sure that it's going to be good to invent our own name
for this, although maybe. But at least I think we should make sure
there are some good comments in an easily discoverable place. Some
people seem to think every programmer in the universe should know what
things like popcount() and fls() and ffs() and stuff like that are,
but it's far from obvious and I often have to refresh my memory. Let's
make it easy for someone to figure out, if they don't know already.
Like just a comment that says "this returns the number of 1 bits in
the integer supplied as an argument" or something can save somebody a
lot of trouble.

-- 
Robert Haas
EDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Paint some PG_USED_FOR_ASSERTS_ONLY in inline functions of ilist.h and bufpage.h
Next
From: Amit Kapila
Date:
Subject: Re: TOAST condition for column size