Re: Boolean operators without commutators vs. ALL/ANY - Mailing list pgsql-hackers

From Greg Stark
Subject Re: Boolean operators without commutators vs. ALL/ANY
Date
Msg-id BANLkTinEXbWix57x7+wak65L45NHHozcEw@mail.gmail.com
Whole thread Raw
In response to Re: Boolean operators without commutators vs. ALL/ANY  (Florian Pflug <fgp@phlo.org>)
Responses Re: Boolean operators without commutators vs. ALL/ANY
List pgsql-hackers
On Fri, Jun 17, 2011 at 3:49 PM, Florian Pflug <fgp@phlo.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


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: pika buildfarm member failure on isolationCheck tests
Next
From: Greg Stark
Date:
Subject: Re: Patch - Debug builds without optimization