Re: VARIANT / ANYTYPE datatype - Mailing list pgsql-hackers

From Robert Haas
Subject Re: VARIANT / ANYTYPE datatype
Date
Msg-id BANLkTinTr7Go5dusFH_6HRMu66tdZ-MxpA@mail.gmail.com
Whole thread Raw
In response to Re: VARIANT / ANYTYPE datatype  (Joseph Adams <joeyadams3.14159@gmail.com>)
Responses Re: VARIANT / ANYTYPE datatype  (Darren Duncan <darren@darrenduncan.net>)
List pgsql-hackers
On Wed, May 11, 2011 at 11:43 AM, Joseph Adams
<joeyadams3.14159@gmail.com> wrote:
> On Tue, May 10, 2011 at 5:19 PM, Darren Duncan <darren@darrenduncan.net> wrote:
>> Examples of open union types could be number, which all the numeric types
>> compose, and so you can know say that you can use the generic numeric
>> operators on values you have simply if their types compose the number union
>> type, and it still works if more numeric types appear later.  Likewise, the
>> string open union could include both text and blob, as both support
>> catenation and substring matches or extraction, for example.
>>
>> This would aid to operator overloading in a generic way, letting you use the
>> same syntax for different types, but allowing types to mix is optional; eg,
>> you could support "add(int,int)" and "add(real,real)" without supporting
>> "add(int,real)" etc but the syntax "add(x,y)" is shared, and you do this
>> while still having a strong type system; allowing the mixing is optional
>> case-by-case.
>
> Coming from a Haskell perspective, this is a great idea, but I don't
> think the "union" feature should be used to implement it.

I'm unclear what the point of such a feature would be.  A union of all
the common numeric types is not much different from the existing type
"numeric".

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: VARIANT / ANYTYPE datatype
Next
From: Tom Lane
Date:
Subject: Re: Fix for bug in ldapServiceLookup in libpq