Re: Function sugnature with default parameter

Поиск
Список
Период
Сортировка
От David Johnston
Тема Re: Function sugnature with default parameter
Дата
Msg-id 1393439496691-5793739.post@n5.nabble.com
обсуждение исходный текст
Ответ на Function sugnature with default parameter  (salah jubeh <s_jubeh@yahoo.com>)
Список pgsql-hackers
salah jubeh wrote
> Hello,
>
> I find default values confusing when a function is overloaded, below is an
> example.
>
>
> CREATE OR REPLACE FUNCTION default_test (a INT DEFAULT 1, b INT DEFAULT 1,
> C INT DEFAULT 1) RETURNS INT AS
> $$
>     BEGIN
>         RETURN a+b+c;
>     END;
> $$
> LANGUAGE 'plpgsql';

Provide a real use-case for this need and maybe someone will consider it
worthwhile to implement.

In the meantime use VARIADIC or define only the longest-default signature
and provide reasonable default values for all optional arguments.  In this
case the defaults should be zero, not one.

Or don't make any of the arguments DEFAULT and provide as many overloads as
you use.  The whole point of DEFAULT was to avoid having to do this for
simple cases - you are not compelled to use default values if your use-case
is too complex for them.

Or just avoid overloading and use different names that describe better what
the different versions accomplish.

Specifying "DEFAULT" in the function call seems to defeat the point.

David J.




--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Function-sugnature-with-default-parameter-tp5793737p5793739.html
Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Changeset Extraction v7.7
Следующее
От: Andres Freund
Дата:
Сообщение: Re: Changeset Extraction v7.7