Re: variadic function support

Поиск
Список
Период
Сортировка
Искать
От
Florian G. Pflug
Тема
Re: variadic function support
Дата
Msg-id
487B54D8.9020407@phlo.org
Ответ на
Список
Дерево обсуждения
variadic function support "Pavel Stehule" <pavel.stehule@gmail.com>
Re: variadic function support Simon Riggs <simon@2ndquadrant.com>
Re: variadic function support "Pavel Stehule" <pavel.stehule@gmail.com>
Re: variadic function support Andrew Dunstan <andrew@dunslane.net>
Re: variadic function support "Pavel Stehule" <pavel.stehule@gmail.com>
Re: variadic function support Tom Lane <tgl@sss.pgh.pa.us>
Re: variadic function support Andrew Dunstan <andrew@dunslane.net>
Re: variadic function support Tom Lane <tgl@sss.pgh.pa.us>
Re: variadic function support Andrew Dunstan <andrew@dunslane.net>
Re: variadic function support Tom Lane <tgl@sss.pgh.pa.us>
Re: variadic function support "Pavel Stehule" <pavel.stehule@gmail.com>
Re: variadic function support "Pavel Stehule" <pavel.stehule@gmail.com>
Re: variadic function support Jeff Davis <pgsql@j-davis.com>
Re: variadic function support Jeff Davis <pgsql@j-davis.com>
Re: variadic function support "Pavel Stehule" <pavel.stehule@gmail.com>
Re: variadic function support Tom Lane <tgl@sss.pgh.pa.us>
Re: variadic function support Jeff Davis <pgsql@j-davis.com>
Re: variadic function support Tom Lane <tgl@sss.pgh.pa.us>
Re: variadic function support "Pavel Stehule" <pavel.stehule@gmail.com>
Re: variadic function support "Florian G. Pflug" <fgp@phlo.org>
Re: variadic function support "Pavel Stehule" <pavel.stehule@gmail.com>
Re: variadic function support Tom Lane <tgl@sss.pgh.pa.us>
Re: variadic function support Tom Lane <tgl@sss.pgh.pa.us>
Re: variadic function support "Pavel Stehule" <pavel.stehule@gmail.com>
Re: variadic function support Tom Lane <tgl@sss.pgh.pa.us>
Re: variadic function support "Pavel Stehule" <pavel.stehule@gmail.com>
Re: variadic function support "Pavel Stehule" <pavel.stehule@gmail.com>
Re: variadic function support Tom Lane <tgl@sss.pgh.pa.us>
Re: variadic function support "Pavel Stehule" <pavel.stehule@gmail.com>
Re: variadic function support Andrew Dunstan <andrew@dunslane.net>
Re: variadic function support "Pavel Stehule" <pavel.stehule@gmail.com>
Re: variadic function support Tom Lane <tgl@sss.pgh.pa.us>
Re: variadic function support "Pavel Stehule" <pavel.stehule@gmail.com>
Re: variadic function support "Pavel Stehule" <pavel.stehule@gmail.com>
Re: variadic function support "Pavel Stehule" <pavel.stehule@gmail.com>
Re: variadic function support Andrew Dunstan <andrew@dunslane.net>
Re: variadic function support "Pavel Stehule" <pavel.stehule@gmail.com>
Re: variadic function support "Pavel Stehule" <pavel.stehule@gmail.com>
Re: variadic function support Jeff Davis <pgsql@j-davis.com>
Re: variadic function support "Pavel Stehule" <pavel.stehule@gmail.com>
Re: variadic function support Jeff Davis <pgsql@j-davis.com>
Re: variadic function support "Pavel Stehule" <pavel.stehule@gmail.com>
Pavel Stehule wrote:
>> One issue that just occurred to me: what if a variadic function 
>> wants to turn around and call another variadic function, passing 
>> the same array argument on to the second one?  This is closely akin
>>  to the problem faced by C "..." functions, and the solutions are 
>> pretty ugly (sprintf vs vsprintf for instance).  Can we do any 
>> better?  At least in the polymorphic case, I'm not sure we can :-(.
>>  maybe with some flag like PARAMS?
> 
> SELECT least(PARAMS ARRAY[1,2,3,4,5,6])

Just FYI, this is more or less how ruby handles variadic functions - a
"*" before the last argument in the function's *definition* causes all
additional arguments to be stored in an array, while a "*" before the
last argument in a function *call* expands an array into single arguments.

So, you could e.g do
def variadic1(a, b, *c)
   # c is in array containing all parameters after second one.
end

def variadic_wrapper(a, *b)
   variadic1("foobar", a, *b)
end

So there is precedent for the "flag idea" too. Plus, I kind of like the
idea of using the same syntax for both wrapping and unwrapping of 
variadic arguments.

regards, Florian Pflug

В списке pgsql-patches по дате отправления
От: Pavel Stehule
Дата:
Сообщение: Re: variadic function support
От: Pavel Stehule
Дата:
Сообщение: Re: variadic function support
FAQ