Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Patches > Re: variadic fu...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 3895 of 4098
Post > Topic >>

Re: variadic function sup****t

by fgp@[EMAIL PROTECTED] ("Florian G. Pflug") Jul 14, 2008 at 03:30 PM

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


-- 
Sent via pgsql-patches mailing list (pgsql-patches@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches
 




 2 Posts in Topic:
Re: variadic function support
pavel.stehule@[EMAIL PROT  2008-07-14 09:26:41 
Re: variadic function support
fgp@[EMAIL PROTECTED] (&  2008-07-14 15:30:00 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Oct 15 20:47:53 CDT 2008.