Re: Variadic parameters vs parameter defaults

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Variadic parameters vs parameter defaults
Date: 2008-12-17 18:32:00
Message-ID: 1414.1229538720@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jeff Davis <pgsql(at)j-davis(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2008-12-17 18:32:41 Re: Variadic parameters vs parameter defaults
Previous Message Jeff Davis 2008-12-17 18:24:59 Re: Variadic parameters vs parameter defaults