Re: Issues for named/mixed function notation patch

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: Issues for named/mixed function notation patch
Дата
Msg-id 162867790910071432s136f03a9ud5d08008af1282bf@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Issues for named/mixed function notation patch  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Issues for named/mixed function notation patch  (Jeff Davis <pgsql@j-davis.com>)
Список pgsql-hackers
2009/10/7 Tom Lane <tgl@sss.pgh.pa.us>:
> Pavel Stehule <pavel.stehule@gmail.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.

It's same as my origin ideas, much better formulated. It is ok for me.

Pavel

>
> Comments?
>
>                        regards, tom lane
>


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

Предыдущее
От: Marko Tiikkaja
Дата:
Сообщение: Re: Writeable CTEs and side effects
Следующее
От: Jeff Davis
Дата:
Сообщение: Re: Issues for named/mixed function notation patch