Re: Boolean operators without commutators vs. ALL/ANY
От | Alvaro Herrera |
---|---|
Тема | Re: Boolean operators without commutators vs. ALL/ANY |
Дата | |
Msg-id | 1308274284-sup-6485@alvh.no-ip.org обсуждение исходный текст |
Ответ на | Re: Boolean operators without commutators vs. ALL/ANY (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: Boolean operators without commutators vs. ALL/ANY
|
Список | pgsql-hackers |
Excerpts from Tom Lane's message of jue jun 16 17:33:17 -0400 2011: > Peter Eisentraut <peter_e@gmx.net> writes: > > I don't really agree that visual correlation needs to trump everything. > > If say > > foo =~ bar > > and > > foo ~= bar > > were to produce completely different results, this would introduce bugs > > all over the place. > > Huh? That's about like arguing that standard mathematical notation is > broken because a < b and a > b don't produce the same result. The difference is that the mnemonic for > and < is very simple and in widespread knowledge; not something I would say for =~'s rule of "the ~ is on the side of the regexp". I know I used to get it wrong in Perl (i.e. I wrote ~= occasionally). To make matters worse, our delimiters for regexes are the same as for strings, the single quote. So you get foo =~ 'bar' /* foo is the text column, bar is the regex */ 'bar' =~ foo /* no complaint but it's wrong */ 'bar' ~= foo /* okay */ 'foo' ~= bar /* no complaint but it's wrong */ How do I tell which is the regex here? If we used, say, /, that would be a different matter: foo =~ /bar/ /bar/ ~= foo /* both okay */ If we had that and you get it wrong, the parser would immediately barf at you if you got it wrong: /bar/ =~ foo /* wrong: LHS wanted text, got regex */ foo ~= /bar/ /* wrong: LHS wanted regex, got text */ (Note: I'm not suggesting we use / as delimiter. This is just an example.) -- Álvaro Herrera <alvherre@commandprompt.com> The PostgreSQL Company - Command Prompt, Inc. PostgreSQL Replication, Consulting, Custom Development, 24x7 support
В списке pgsql-hackers по дате отправления: