Re: Variadic parameters vs parameter defaults - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Variadic parameters vs parameter defaults
Date
Msg-id 1414.1229538720@sss.pgh.pa.us
Whole thread Raw
In response to Re: Variadic parameters vs parameter defaults  (Jeff Davis <pgsql@j-davis.com>)
List 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 by date:

Previous
From: Jeff Davis
Date:
Subject: Re: Variadic parameters vs parameter defaults
Next
From: Peter Eisentraut
Date:
Subject: Re: Variadic parameters vs parameter defaults