Re: Issues for named/mixed function notation patch
От | Tom Lane |
---|---|
Тема | Re: Issues for named/mixed function notation patch |
Дата | |
Msg-id | 2948.1254949098@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: Issues for named/mixed function notation patch (Pavel Stehule <pavel.stehule@gmail.com>) |
Ответы |
Re: Issues for named/mixed function notation patch
Re: Issues for named/mixed function notation patch |
Список | pgsql-hackers |
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. Comments? regards, tom lane
В списке pgsql-hackers по дате отправления: