Re: Variadic parameters vs parameter defaults

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Variadic parameters vs parameter defaults
Дата
Msg-id 1414.1229538720@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Variadic parameters vs parameter defaults  (Jeff Davis <pgsql@j-davis.com>)
Список pgsql-hackers
Jeff Davis <pgsql@j-davis.com> writes:
> Previous discussion link:
> http://archives.postgresql.org/pgsql-patches/2008-07/msg00149.php

> You can make either mechanism do what you want by defining the right set
> of functions. If a minimum of one argument per variadic parameter is
> required, you can work around it by defining an extra function with no
> variadic parameter to handle the zero-argument case.

I think the bottom line here is that we need to make it possible for the
user to define what happens in the corner case.  One of the problems
mentioned in the prior thread was that foo(variadic int[]) and
foo(variadic text[]) would conflict if it were possible to match both
to a zero-argument call.  There's no principled solution to that if the
system insists on defining the behavior for zero args.  However, with
the behavior I propose now, the user could determine which one is used
by giving a default to it and not the other one.  That is,
foo(variadic int[] = array[]::int[])foo(variadic text[])

causes the int[] one to get used for "foo()", and if you want the other
choice you hang the default on that one instead.
        regards, tom lane


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

Предыдущее
От: Jeff Davis
Дата:
Сообщение: Re: Variadic parameters vs parameter defaults
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: Variadic parameters vs parameter defaults