Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l1u1S-000374-QX for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Jan 2021 16:38:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l1u1R-0001rP-PY for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Jan 2021 16:38:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l1u1R-0001rC-6w for pgsql-hackers@lists.postgresql.org; Tue, 19 Jan 2021 16:38:25 +0000 Received: from xvm-110-146.dc2.ghst.net ([46.226.110.146] helo=fetter.org) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l1u1N-0003h0-Os for pgsql-hackers@postgresql.org; Tue, 19 Jan 2021 16:38:24 +0000 Received: by fetter.org (Postfix, from userid 1001) id 760DC41D34; Tue, 19 Jan 2021 17:38:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fetter.org; s=default; t=1611074299; bh=oD988WOE17YeztNs9W4qWJr8QRqS/+zB2P5oOJCthr0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=W0n7fmWgVvONgbjyIZ7pM7ezvH2JYy6FHInFNTDynABDgZkmKHMsmUwJUD7HpY3wR QKwM1q/iGNrRzW1unrNGVvQauE4yDx/PuxBFn5Q9mSHybvsOvaTbKdn0B/ly+gIQxK i0S0ekRLyeHDZ/DY/xzACxG1aMsdBPGmZCKoz+qG0G+/NZqkxtFqsz383j4CgrhonB oedLc7ySghkYDmrRNaz86VX6XHSTzEnB1llutKBP/PfleDtfa60P6at0CSLcR74el3 8C8sJoRp+2ViaX9neqx/LSNVi+Ax3C9Y8Rnb1a+3uRx1JbFWFBjB40KUdxpKSI/Y4+ xEaJi++jltVqQ== Date: Tue, 19 Jan 2021 17:38:19 +0100 From: David Fetter To: Robert Haas Cc: Peter Eisentraut , Tom Lane , Daniel Verite , PostgreSQL Development , Vik Fearing Subject: Re: popcount Message-ID: <20210119163818.GE8721@fetter.org> References: <20201230105535.GJ13234@fetter.org> <5ea2932e-50f5-4a74-9550-5e3291b6652b@manitou-mail.org> <20201230164108.GK13234@fetter.org> <20210111161354.GA8721@fetter.org> <338981.1610984050@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, Jan 19, 2021 at 07:58:12AM -0500, Robert Haas wrote: > On Tue, Jan 19, 2021 at 3:06 AM Peter Eisentraut > wrote: > > On 2021-01-18 16:34, Tom Lane wrote: > > > Peter Eisentraut 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 > > , 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. I went with count_set_bits() for the next version, and I hope that helps clarify what it does. > 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. You bring up an excellent point, which is that our builtin functions could use a lot more documentation directly to hand than they now have. For example, there's a lot of needless ambiguity created by function comments which leave it up in the air as to which positional argument does what in functions like string_to_array, which take multiple arguments. I'll try to get a patch in for the next CF with a fix for that, and a separate one that doesn't put it on people to use \df+ to find the comments we do provide. There have been proposals for including an optional space for COMMENT ON in DDL, but I suspect that those won't fly unless and until they make their way into the standard. Best, David. -- David Fetter http://fetter.org/ Phone: +1 415 235 3778 Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate