On Thu, Mar 4, 2021, at 16:21, Isaac Morland wrote:
> On Thu, 4 Mar 2021 at 01:25, Joel Jacobson <j...@compiler.org> wrote:
> 
>> __
>> Suggestion #1: Use [] as the canonical form for discrete types.
>> This would allow creating ranges for all values for discrete types.
> 
> I won't reiterate here, but there are fundamental reasons why [) is 
> definitely the right default and canonical form.

It would be interesting to hear the reasons.

For discrete types, there are only exact values, there is nothing in between 
two adjacent discrete values.
So if we mean a range covering only the integer 5, why can't we just say [5,5] 
which simply means "5"?
Why is it necessary to express it as [5,6) which I interpret as the much more 
complex "all integers from 5 up until just before the integer 6".

We know for sure nothing can exist after 5 before 6, it's void, so why is it 
necessary to be explicit about including this space which we know can't contain 
any values?

For discrete types, we wouldn't even need the inclusive/exclusive features at 
all.

> 
> In any case, you can create a range containing the last value:
> 
> odyssey=> select 2147483647 <@ int4range (0, null);
>  ?column? 
> ----------
>  t
> (1 row)
> 
> odyssey=> 
> 
> It does seem reasonable to me to change it so that specifying the last value 
> as the right end with ] would use a null endpoint instead of producing an 
> error when it tries to increment the bound.

Neat hack, thanks.

/Joel

Reply via email to