Re: Variadic parameters vs parameter defaults

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Brendan Jurd" <direvus(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Variadic parameters vs parameter defaults
Date: 2008-12-17 01:23:49
Message-ID: 18723.1229477029@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Brendan Jurd" <direvus(at)gmail(dot)com> writes:
> On Wed, Dec 17, 2008 at 11:07 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> ISTM one could make a pretty good argument that this last case should
>> succeed, producing an empty-array argument. If you buy that, then it
>> is sensible to forbid defaults for variadics,

> Yep, +1 for this approach. I would intuitively expect that, if I omit
> variadic argument(s) when calling a function, that the function ends
> up getting an empty array of the appropriate type.

Actually, I just realized that there's another fly in the ointment:
the current variadic code allows "variadic anyarray", which is
equivalent to an appropriate number of anyelement arguments. If we
allow defaulting then there's a big problem: no principled way to
decide what type the empty array is.

The explicit-default solution would work around that, by making the
user say what type he wants. However it puts us right back into the
situation of having a default for a polymorphic argument, which I
was hoping to avoid.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2008-12-17 01:33:36 Re: [ADMIN] shared_buffers and shmmax
Previous Message Brendan Jurd 2008-12-17 01:18:10 Re: Variadic parameters vs parameter defaults