unary operators, precedence, grouping

From: "woger151" <woger151(at)jqpx37(dot)cotse(dot)net>
To: <pgsql-general(at)postgresql(dot)org>
Subject: unary operators, precedence, grouping
Date: 2007-03-10 13:05:41
Message-ID: 000901c76314$d412b500$6401a8c0@apollosjf
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I defined a function, count_nonnull, to return 1 if not null, 0 otherwise.
Then I defined a corresponding unary operator <~~. I wanted it for
expressions like <~~ item_1 + <~~ item_2. But because precedence of
user-defined ops is pretty low, I had to rewrite this as <~~(item_1) +
<~~(item_2), which is already no more efficient in use of parentheses than
count_nonnull.

Even worse, however, it turns out that _more_ parentheses were needed:
(<~~(item_1)) + (<~~(item_2)).

Why wouldn't <~~(item_1) + <~~(item_2) be parsed as (<~~(item_1)) +
(<~~(item_2))?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dan Sugalski 2007-03-10 13:30:20 Re: Moving from 32 to 64 bit builds on Solaris
Previous Message Jorge Godoy 2007-03-10 11:07:54 Re: OT: Canadian Tax Database