Re: Variadic parameters vs parameter defaults

Поиск
Список
Период
Сортировка
От Gregory Stark
Тема Re: Variadic parameters vs parameter defaults
Дата
Msg-id 877i5zoc2a.fsf@oxford.xeocode.com
обсуждение исходный текст
Ответ на Variadic parameters vs parameter defaults  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Variadic parameters vs parameter defaults  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Tom Lane <tgl@sss.pgh.pa.us> writes:

> A related point is that, because the current code forbids a default
> for a variadic, you can't do something like
>
> create function foo (f1 int, f2 int default = 42, f3 variadic int[] = array[]::int[])
>
> ie there's no way to have defaults on the preceding parameters either.
> I don't know how useful that is, but maybe it's an argument for adopting
> the second solution where you can explicitly specify a default for a
> variadic.
>
> Comments?

Well if you adopt the implicit empty array argument for missing variadic
parameters then you can just allow defaults for trailing parameters before the
final parameter.

I'm inclined to think an implicit empty array makes the most sense. If a
function-writer wants to enforce a minimum number of arguments they can check
and throw an error.

The question arises though whether it's useful to have any default other than
an empty array. I don't see a compelling reason.

--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com Ask me about EnterpriseDB's 24x7 Postgres support!


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Emmanuel Cecchet
Дата:
Сообщение: [Fwd: Re: Transactions and temp tables]
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: Variadic parameters vs parameter defaults