Re: Boolean operators without commutators vs. ALL/ANY

From: Greg Stark <stark(at)mit(dot)edu>
To: Florian Pflug <fgp(at)phlo(dot)org>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Boolean operators without commutators vs. ALL/ANY
Date: 2011-06-20 01:16:06
Message-ID: BANLkTinEXbWix57x7+wak65L45NHHozcEw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jun 17, 2011 at 3:49 PM, Florian Pflug <fgp(at)phlo(dot)org> wrote:
>> The regex is always to the right of the operator.
>
> Which is something you have to remember... It's not in any
> way deducible from "foo ~ bar" alone.

Except that it's always been this way, going back to perl4 or tcl or
their predecessors. The regexp binding operator always has the regexp
on the right.

>>> How is that worse than the situation with "=~" and "~="?
>>
>> With =~ it is to the right, with ~= it is to the left.
>
> It's always where the tilde is. Yeah, you have to remember that.

And when you get it wrong it will fail silently. No errors, just wrong results.

While I've never accidentally written /foo/ =~ $_ in perl I have
*frequently* forgotten whether the operator is ~= or =~. Actually I
forget that pretty much every time I start writing some perl. I just
put whichever comes first and if I get an error I reverse it.

I can see the temptation to make it symmetric but it's going to cause
an awful lot of confusion.

Perhaps we could name the operators ~~= and =~~ and then have a =~
short-cut for compatibility? (and ~ too I guess?)

--
greg

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2011-06-20 01:39:12 Re: Patch - Debug builds without optimization
Previous Message Robert Haas 2011-06-20 01:10:02 Re: pika buildfarm member failure on isolationCheck tests