Re: Calling PL functions with named parameters

From: Gaetano Mendola <mendola(at)bigfoot(dot)com>
To: Oliver Jowett <oliver(at)opencloud(dot)com>
Subject: Re: Calling PL functions with named parameters
Date: 2004-08-14 08:16:27
Message-ID: 411DCA5B.7080500@bigfoot.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Oliver Jowett wrote:

> Tom Lane wrote:
>
>>> On a related note, it would also be nice to have default
>>> parameters and some way to say to use them.
>>
>>
>>
>> That is fundamentally not ever going to happen, because it blows
>> overloaded-function resolution out of the water: there is no way to
>> choose whether "foo(42, 2.5)" matches foo(int, float) or
>> foo(int, float, something-with-a-default). Let's try to limit our
>> attention to something that might actually work.
>
>
> C++ manages to solve this problem, although I can't remember the exact
> mechanics (and C++ is usually not a good example to follow anyway ;)

Your're wrong:

try to compile this:

void foo( int a, float b ) { }
void foo( int a, float b, int c=0 ) { }

int main(char argc, char **argv)
{
foo( 42, 2.5 );

return 0;
}

you'll get:

a.cpp:6: error: call of overloaded `foo(int, double)' is ambiguous
a.cpp:1: error: candidates are: void foo(int, float)
a.cpp:2: error: void foo(int, float, int)

usualy C++ is not a good example as SQL is not :-)

Regards
Gaetano Mendola

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2004-08-14 08:21:33 Re: Turkish downcasting in PL/pgSQL
Previous Message Gaetano Mendola 2004-08-14 08:08:51 Re: PITR on Windows?