Re: bit|varbit #, xor operator

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: bit|varbit #, xor operator
Date: 2016-10-16 20:13:54
Message-ID: 27484.1476648834@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com> writes:
> Personally I think it was a mistake to use # for intersection. Range
> doesn't do that (using * instead), and AFAICT PostGIS doesn't either
> (preferring &). So I propose renaming those operators, as well as the
> XOR ones. I think ^^ is pretty logical for XOR. I'm not sure about
> intersect... * doesn't seem like a good idea, && is overlaps, maybe &*.

I'm pretty much -1 on renaming any of these existing operators. There's
no realistic hope of having only one interpretation for an operator name
across all the different data types --- the best we can hope for, I think,
is consistency within a datatype family. For example, the reason not to
use ^ for integer XOR is that it also means exponentiation for
float/numeric, which are in the same class of datatypes. And your
proposal of ^^ doesn't satisfy anyone's notion of least astonishment.
As for renaming intersection, renaming operators that have had those names
since Berkeley, and are perfectly consistent within their datatype family,
seems likely to create much more pain than it removes.

As for counting bits in a bitstring, why do we have to make that an
operator at all? Using a function would decrease the stress involved
in choosing a name, and it's hard to believe that the requirement is
so common that we need to shave a few keystrokes. But if you must have
an operator there's not that much wrong with using prefix # for it.

> Related to this I'd also like to add a boolean XOR operator as that's a
> relatively common request/question.

We have boolean XOR; it's spelled "<>".

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kouhei Kaigai 2016-10-17 00:52:30 Steps inside ExecEndGather
Previous Message Jeff Janes 2016-10-16 19:35:40 Re: VACUUM's ancillary tasks