From: | David Johnston <polobo(at)yahoo(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Function sugnature with default parameter |
Date: | 2014-02-26 18:31:36 |
Message-ID: | 1393439496691-5793739.post@n5.nabble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2014-02-26 18:32:30 | Re: Changeset Extraction v7.7 |
Previous Message | Alvaro Herrera | 2014-02-26 18:30:55 | Re: Changeset Extraction v7.7 |