Re: factorial function/phase out postfix operators? - Mailing list pgsql-hackers

From Vik Fearing
Subject Re: factorial function/phase out postfix operators?
Date
Msg-id a020d7ba-7694-28d1-ba46-aafd316be237@postgresfriends.org
Whole thread Raw
In response to Re: factorial function/phase out postfix operators?  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: factorial function/phase out postfix operators?
Re: factorial function/phase out postfix operators?
List pgsql-hackers
On 5/19/20 4:22 PM, Robert Haas wrote:
> On Tue, May 19, 2020 at 9:51 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Uh ... what exactly would be the point of that?  The real reason to do
>> this at all is not that we have it in for '!', but that we want to
>> drop the possibility of postfix operators from the grammar altogether,
>> which will remove a boatload of ambiguity.
> 
> The ambiguity doesn't come from the mere existence of postfix
> operators. It comes from the fact that, when we lex the input, we
> can't tell whether a particular operator that we happen to encounter
> is prefix, infix, or postfix. So hard-coding, for example, a rule that
> '!' is always a postfix operator and anything else is never a postfix
> operator is sufficient to solve the key problems. Then "SELECT a ! b"
> can only be a postfix operator application followed by a column
> labeling, a "SELECT a + b" can only be the application of an infix
> operator.

So if I make a complex UDT where a NOT operator makes a lot of sense[*],
why wouldn't I be allowed to make a prefix operator ! for it?  All for
what?  That one person in the corner over there who doesn't want to
rewrite their query to use factorial() instead?

I'm -1 on keeping ! around as a hard-coded postfix operator.


[*] I don't have a concrete example in mind, just this abstract one.
-- 
Vik Fearing



pgsql-hackers by date:

Previous
From: Christoph Berg
Date:
Subject: Re: ldap tls test fails in some environments
Next
From: Fujii Masao
Date:
Subject: Re: pg_stat_wal_receiver and flushedUpto/writtenUpto