Re: Issues for named/mixed function notation patch

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Jeff Davis <pgsql(at)j-davis(dot)com>, Bernd Helmle <mailings(at)oopsware(dot)de>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Issues for named/mixed function notation patch
Date: 2009-10-07 20:58:18
Message-ID: 2948.1254949098@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
>> Sorry, I'm having trouble understanding what you're driving at here.
>> I think we should just not allow named notation to be combined with
>> VARIADIC, at least for a first version of this feature, either when
>> defining a function or when calling one. We can consider relaxing
>> that restriction at a later date if we can agree on what the semantics
>> should be.

> This is maybe too strict. I thing, so safe version is allow variadic
> packed parameter with VARIADIC keyword as Jeff proposes.

I'm working through this patch now, and I find myself not very satisfied
on the question of variadic versus named arguments. What the latest
patch actually does is:

* completely ignores variadic functions when trying to match
a call having any named arguments

* does not throw an error for use of the VARIADIC keyword
in a call together with named arguments

Neither of these behaviors quite seem to me to satisfy the principle of
least astonishment, and in combination they definitely do not.

It seems to me that there is not anything wrong with using named
arguments together with VARIADIC and getting a match to a variadic
function. VARIADIC in the argument list essentially turns off the
special behavior of variadic functions, and after that you might as
well allow either named or positional matching. (I guess if you
wanted to be really strict you'd insist that the VARIADIC keyword
be attached to the specific named argument that matches the variadic
parameter, but I don't mind being a bit lax there.)

When VARIADIC is not specified, then I think that silently ignoring
variadic functions for a named-argument call is probably reasonable.
This can be argued by imagining that the function's implicit array
element parameters do not have any names (the variadic array parameter
might have a name, but the elements generated from it do not). Since
these must be at the right end of the effective parameter list, and we
only allow named arguments at the right of the call list, there is no
way for the named arguments to match non-variadic named parameters and
still have anything matching to the variadic array elements. Therefore
a variadic function can never match such a call and ignoring it isn't
surprising.

Comments?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marko Tiikkaja 2009-10-07 21:08:03 Writeable CTEs and side effects
Previous Message Chris Browne 2009-10-07 19:55:40 Re: Rules: A Modest Proposal