Re: VARIANT / ANYTYPE datatype

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Joseph Adams <joeyadams3(dot)14159(at)gmail(dot)com>
Cc: Darren Duncan <darren(at)darrenduncan(dot)net>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: VARIANT / ANYTYPE datatype
Date: 2011-05-11 16:24:26
Message-ID: BANLkTinTr7Go5dusFH_6HRMu66tdZ-MxpA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, May 11, 2011 at 11:43 AM, Joseph Adams
<joeyadams3(dot)14159(at)gmail(dot)com> wrote:
> On Tue, May 10, 2011 at 5:19 PM, Darren Duncan <darren(at)darrenduncan(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-05-11 16:27:17 Re: Fix for bug in ldapServiceLookup in libpq
Previous Message Alvaro Herrera 2011-05-11 16:02:53 Re: VARIANT / ANYTYPE datatype