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 3892 of 4249
Post > Topic >>

Re: variadic function sup****t

by tgl@[EMAIL PROTECTED] (Tom Lane) Jul 13, 2008 at 12:32 PM

"Pavel Stehule" <pavel.stehule@[EMAIL PROTECTED]
> writes:
> 2008/7/13 Jeff Davis <pgsql@[EMAIL PROTECTED]
>:
>> Also, it doesn't seem to allow calls to a variadic function with zero
>> arguments, e.g. "mleast()". I think this should be allowed.

> It's not possible for all cases, because empty array have be typed
> array still. But for non polymorphic variadic functions it's probably
> possible - I would to solve this question later - and for now use
> overloading etc

I don't really like the idea of a feature that would work except in the
polymorphic case --- that just seems too non-orthogonal.  Also I tend
to think that a pretty large fraction of variadic functions will be
polymorphic, making the feature's usefulness even more dubious.

I concur with the idea that variadic functions should only match to
calls that offer at least one value for the variadic array.  If you can
actually define the behavior sensibly for the zero-element case, a
separate function of the same name can cover that case.

As far as the "variadic int" versus "variadic int[]" business, I'm
starting to agree with Pavel that "variadic int[]" offers less potential
for confusion.  In particular, it seems to make it more obvious for the
function author that the argument he receives is an array.  Also, the
other one would mean that what we put into pg_proc.proargtypes doesn't
agree directly with what the user thinks the argument types are.  While
I think we could force that to work, it's not exactly satisfying the
principle of least surprise.


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 :-(.

			regards, tom lane

-- 
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-13 08:32:43 
Re: variadic function support
tgl@[EMAIL PROTECTED] (T  2008-07-13 12:32:08 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Mon Dec 1 11:37:02 CST 2008.