Re: Proposition to use '==' as synonym for 'IS NOT DISTINCT FROM'

From: Diggory Blake <diggsey(at)googlemail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Eugen Konkov <kes-kes(at)yandex(dot)ru>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, David Fetter <david(at)fetter(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Proposition to use '==' as synonym for 'IS NOT DISTINCT FROM'
Date: 2019-10-28 13:08:15
Message-ID: CAAnrWj-a6vbR3mJYa68XkMZpBgLjU-kuyy0kDEP-B8S3j9MS3Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Would it be possible to just use `IS`, `IS NOT` instead of `IS [NOT]
DISTINCT FROM`? It's always surprised me that you can write `IS NULL`, `IS
TRUE`, etc. but they're all special-cased. I could see it introducing a
parsing ambiguity, but it doesn't seem impossible to resolve?

On Mon, Oct 28, 2019 at 12:49 PM Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
wrote:

>
>
> po 28. 10. 2019 v 12:39 odesílatel Eugen Konkov <kes-kes(at)yandex(dot)ru>
> napsal:
>
>> > x IS NOT DISTINCT FROM y
>>
>> > I'm vaguely imagining
>>
>> > x = {magic} y
>>
>> > where unlike Eugen's suggestion, "=" is the real name of the underlying
>> > comparison operator. For dump/restore this could be spelled verbosely
>> > as
>>
>> > x OPERATOR(someplace.=) {magic} y
>>
>> > The hard part is to figure out some {magic} annotation that is both
>> > short and unambiguous. We have to cover the IS DISTINCT variant, too.
>>
>> I am from Perl world. There are == and != operators.
>> Here short snippet of code:
>>
>> my $x = undef;
>> my $y = 'some value';
>> my $z = undef;
>> $x == $y; # FALSE
>> $x == $z; # TRUE
>> $x != $y ; # TRUE
>> $x != $z; # FALSE
>>
>>
>> > x OPERATOR(someplace.=) {magic} y
>> If we should follow this form, then IS DISTINCT should be written as:
>> x =! y
>> This looks unusual, because JavaScript also follow != form. so I hope
>> it will be easy to detect/implement != form, which I used to read as:
>> negate the result of comparison
>>
>>
>>
>> Can we supply additional parameters to OPERATOR via double
>> parentheses( double parentheses is another crazy idea)?
>> x =(( 'NULL' )) y
>>
>
> It's looks much more terrible than original IS DISTINCT FROM
>
>
>> or
>>
>> x OPERATOR(someplace.=, magic ) y
>> which will be internally converted( I suppose ) to OPERATOR(
>> someplace.=, x, y, magic )
>>
>
> I don't think so benefit of this is too valuable against possible problems.
>
> MySQL has special operator <=>, so if we implement some, then we should to
> implement this. But better do nothing. I don't see significant benefit of
> this against costs.
>
> Pavel
>
>>
>> --
>> Best regards,
>> Eugen Konkov
>>
>>
>>
>>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2019-10-28 13:31:59 Re: Proposition to use '==' as synonym for 'IS NOT DISTINCT FROM'
Previous Message Robert Haas 2019-10-28 13:05:40 Re: Add const qualifiers to internal range type APIs