Re: Precedence of Postfix operators - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Precedence of Postfix operators
Date
Msg-id 24430.1265561078@sss.pgh.pa.us
Whole thread Raw
In response to Precedence of Postfix operators  (Gokulakannan Somasundaram <gokul007@gmail.com>)
Responses Re: Precedence of Postfix operators
List pgsql-hackers
Gokulakannan Somasundaram <gokul007@gmail.com> writes:
>    Is there any reason why we have given lesser precedence for postfix
> operator compared to multiplication/division? Usually postfix operators have
> more precedence than the binary operations. Is this some kind of work around
> to provide user-defined operators? Can someone help me understand this?

A bit of poking in the CVS logs for gram.y reveals

2001-01-23 17:39  tgl
* src/backend/parser/gram.y: Give 'a_expr ::= a_expr Op' productiona slightly lower precedence than Op, so that the
sequence'a_exprOp Op a_expr' will be parsed as a_expr Op (Op a_expr) not (a_exprOp) Op a_expr as formerly.  In other
words,prefer treatinguser-defined operators as prefix operators to treating them aspostfix operators, when there is an
ambiguity.   Also clean up acouple of other infelicities in production priority assignment ---for example, BETWEEN
wasn'tbeing given the intended priority, butthat of AND.
 

There are several other nasty things that we've had to do in order to
keep supporting postfix operators at all.  I thibk most people view them
as a legacy feature best avoided.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Joachim Wieland
Date:
Subject: Re: Listen / Notify - what to do when the queue is full
Next
From: Simon Riggs
Date:
Subject: Re: Hot Standby and DROP DATABASE