pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Reference function arguments by name
8+ messages / 5 participants
[nested] [flat]

* Reference function arguments by name
@ 2013-05-09 20:46 Erwin Brandstetter <brandstetter@falter.at>
  2013-05-11 08:13 ` Re: Reference function arguments by name Sian Mountbatten <poenikatu@fastmail.co.uk>
  2013-05-11 10:23 ` Re: Reference function arguments by name Erik Rijkers <er@xs4all.nl>
  2013-05-11 16:10 ` Re: Reference function arguments by name Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 3 replies; 8+ messages in thread

From: Erwin Brandstetter @ 2013-05-09 20:46 UTC (permalink / raw)
  To: pgsql-docs

Hi!

The manual says here:
http://www.postgresql.org/docs/current/interactive/sql-createfunction.html
http://www.postgresql.org/docs/devel/static/sql-createfunction.html

> argname
>
>     The name of an argument. Some languages (currently only PL/pgSQL)
>     let you use the name in the function body. For other languages the
>     name of an input argument is just extra documentation, so far as
>     the function itself is concerned; but you can use input argument
>     names when calling a function to improve readability (see Section
>     4.3
>     <http://www.postgresql.org/docs/current/interactive/sql-syntax-calling-funcs.html;).
>     In any case, the name of an output argument is significant,
>     because it defines the column name in the result row type. (If you
>     omit the name for an output argument, the system will choose a
>     default column name.)
>

This has changed in version 9.2. SQL functions can reference the name. Ergo:

s /(currently only PL/pgSQL) / (currently only PL/pgSQL and SQL)


I tested it and it's /correctly /documented here:
http://www.postgresql.org/docs/current/interactive/xfunc-sql.html#XFUNC-SQL-FUNCTION-ARGUMENTS

 > Arguments of a SQL function can be referenced in the function body 
using either names or numbers.


Regards
Erwin

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Reference function arguments by name
  2013-05-09 20:46 Reference function arguments by name Erwin Brandstetter <brandstetter@falter.at>
@ 2013-05-11 08:13 ` Sian Mountbatten <poenikatu@fastmail.co.uk>
  2013-05-11 08:20   ` Re: Reference function arguments by name Erwin Brandstetter <brandstetter@falter.at>
  2 siblings, 1 reply; 8+ messages in thread

From: Sian Mountbatten @ 2013-05-11 08:13 UTC (permalink / raw)
  To: Erwin Brandstetter <brandstetter@falter.at>; pgsql-docs

On 2013-05-09 21:46, Erwin Brandstetter wrote:
> Hi!
>
> The manual says here:
> http://www.postgresql.org/docs/current/interactive/sql-createfunction.html
> http://www.postgresql.org/docs/devel/static/sql-createfunction.html
>
>> argname
>>
>>     The name of an argument. Some languages (currently only PL/pgSQL)
>>     let you use the name in the function body. For other languages
>>     the name of an input argument is just extra documentation, so far
>>     as the function itself is concerned; but you can use input
>>     argument names when calling a function to improve readability
>>     (see Section 4.3
>>     <http://www.postgresql.org/docs/current/interactive/sql-syntax-calling-funcs.html;).
>>     In any case, the name of an output argument is significant,
>>     because it defines the column name in the result row type. (If
>>     you omit the name for an output argument, the system will choose
>>     a default column name.)
>>
>
> This has changed in version 9.2. SQL functions can reference the name. 
> Ergo:
>
> s /(currently only PL/pgSQL) / (currently only PL/pgSQL and SQL)
>
>
> I tested it and it's /correctly /documented here:
> http://www.postgresql.org/docs/current/interactive/xfunc-sql.html#XFUNC-SQL-FUNCTION-ARGUMENTS
>
> > Arguments of a SQL function can be referenced in the function body 
> using either names or numbers.
>
>
> Regards
> Erwin
It looks strongly that you people are of the opinion that "the code 
documents
itself". That is a myth produced by lazy software developers who cannot 
document
their code properly. You ought to be using Cweb for C code. Have a look at
the code for SQLite to see how comments in C can be used to provide decent
documentation

Fortunately, I do not use C. I prefer a HIGH-level language :-)

-- 
Sian Mountbatten
Algol 68 Specialist

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Reference function arguments by name
  2013-05-09 20:46 Reference function arguments by name Erwin Brandstetter <brandstetter@falter.at>
  2013-05-11 08:13 ` Re: Reference function arguments by name Sian Mountbatten <poenikatu@fastmail.co.uk>
@ 2013-05-11 08:20   ` Erwin Brandstetter <brandstetter@falter.at>
  2013-05-11 09:33     ` Re: Reference function arguments by name Sian Mountbatten <poenikatu@fastmail.co.uk>
  0 siblings, 1 reply; 8+ messages in thread

From: Erwin Brandstetter @ 2013-05-11 08:20 UTC (permalink / raw)
  To: Sian Mountbatten <poenikatu@fastmail.co.uk>; +Cc: pgsql-docs


On 11.05.2013 10:13, Sian Mountbatten wrote:
> On 2013-05-09 21:46, Erwin Brandstetter wrote:
>> Hi!
>>
>> The manual says here:
>> http://www.postgresql.org/docs/current/interactive/sql-createfunction.html
>> http://www.postgresql.org/docs/devel/static/sql-createfunction.html
>>
>>> argname
>>>
>>>     The name of an argument. Some languages (currently only
>>>     PL/pgSQL) let you use the name in the function body. For other
>>>     languages the name of an input argument is just extra
>>>     documentation, so far as the function itself is concerned; but
>>>     you can use input argument names when calling a function to
>>>     improve readability (see Section 4.3
>>>     <http://www.postgresql.org/docs/current/interactive/sql-syntax-calling-funcs.html;).
>>>     In any case, the name of an output argument is significant,
>>>     because it defines the column name in the result row type. (If
>>>     you omit the name for an output argument, the system will choose
>>>     a default column name.)
>>>
>>
>> This has changed in version 9.2. SQL functions can reference the 
>> name. Ergo:
>>
>> s /(currently only PL/pgSQL) / (currently only PL/pgSQL and SQL)
>>
>>
>> I tested it and it's /correctly /documented here:
>> http://www.postgresql.org/docs/current/interactive/xfunc-sql.html#XFUNC-SQL-FUNCTION-ARGUMENTS
>>
>> > Arguments of a SQL function can be referenced in the function body 
>> using either names or numbers.
>>
>>
>> Regards
>> Erwin
> It looks strongly that you people are of the opinion that "the code 
> documents
> itself". That is a myth produced by lazy software developers who 
> cannot document
> their code properly. You ought to be using Cweb for C code. Have a look at
> the code for SQLite to see how comments in C can be used to provide decent
> documentation
>
> Fortunately, I do not use C. I prefer a HIGH-level language :-)

This reply seems unrelated.

Regards
Erwin

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Reference function arguments by name
  2013-05-09 20:46 Reference function arguments by name Erwin Brandstetter <brandstetter@falter.at>
  2013-05-11 08:13 ` Re: Reference function arguments by name Sian Mountbatten <poenikatu@fastmail.co.uk>
  2013-05-11 08:20   ` Re: Reference function arguments by name Erwin Brandstetter <brandstetter@falter.at>
@ 2013-05-11 09:33     ` Sian Mountbatten <poenikatu@fastmail.co.uk>
  0 siblings, 0 replies; 8+ messages in thread

From: Sian Mountbatten @ 2013-05-11 09:33 UTC (permalink / raw)
  To: Erwin Brandstetter <brandstetter@falter.at>; pgsql-docs

On 2013-05-11 09:20, Erwin Brandstetter wrote:
>
> On 11.05.2013 10:13, Sian Mountbatten wrote:
>> On 2013-05-09 21:46, Erwin Brandstetter wrote:
>>> Hi!
>>>
>>> The manual says here:
>>> http://www.postgresql.org/docs/current/interactive/sql-createfunction.html
>>> http://www.postgresql.org/docs/devel/static/sql-createfunction.html
>>>
>>>> argname
>>>>
>>>>     The name of an argument. Some languages (currently only
>>>>     PL/pgSQL) let you use the name in the function body. For other
>>>>     languages the name of an input argument is just extra
>>>>     documentation, so far as the function itself is concerned; but
>>>>     you can use input argument names when calling a function to
>>>>     improve readability (see Section 4.3
>>>>     <http://www.postgresql.org/docs/current/interactive/sql-syntax-calling-funcs.html;).
>>>>     In any case, the name of an output argument is significant,
>>>>     because it defines the column name in the result row type. (If
>>>>     you omit the name for an output argument, the system will
>>>>     choose a default column name.)
>>>>
>>>
>>> This has changed in version 9.2. SQL functions can reference the 
>>> name. Ergo:
>>>
>>> s /(currently only PL/pgSQL) / (currently only PL/pgSQL and SQL)
>>>
>>>
>>> I tested it and it's /correctly /documented here:
>>> http://www.postgresql.org/docs/current/interactive/xfunc-sql.html#XFUNC-SQL-FUNCTION-ARGUMENTS
>>>
>>> > Arguments of a SQL function can be referenced in the function body 
>>> using either names or numbers.
>>>
>>>
>>> Regards
>>> Erwin
>> It looks strongly that you people are of the opinion that "the code 
>> documents
>> itself". That is a myth produced by lazy software developers who 
>> cannot document
>> their code properly. You ought to be using Cweb for C code. Have a 
>> look at
>> the code for SQLite to see how comments in C can be used to provide 
>> decent
>> documentation
>>
>> Fortunately, I do not use C. I prefer a HIGH-level language :-)
>
> This reply seems unrelated.
>
> Regards
> Erwin
The point is that documentation of the code always takes 2nd place. Why
argue about readability when the only help you give to anybody who is
unfortunate enough to have to maintain your software are names of variables?
It doesn't matter a damn whether you put names in or out of a function.
What matters is what help do you give your hapless maintainers?

Sincerely

-- 
Sian Mountbatten
Algol 68 Specialist

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Reference function arguments by name
  2013-05-09 20:46 Reference function arguments by name Erwin Brandstetter <brandstetter@falter.at>
@ 2013-05-11 10:23 ` Erik Rijkers <er@xs4all.nl>
  2 siblings, 0 replies; 8+ messages in thread

From: Erik Rijkers @ 2013-05-11 10:23 UTC (permalink / raw)
  To: Erwin Brandstetter <brandstetter@falter.at>; +Cc: pgsql-docs

On Thu, May 9, 2013 22:46, Erwin Brandstetter wrote:
> This has changed in version 9.2. SQL functions can reference the name. Ergo:
>
> s /(currently only PL/pgSQL) / (currently only PL/pgSQL and SQL)
>
>

Here is the patch (don't feed them Battenbergs).

-- 
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs

Attachments:

sql-createfunction.diff (application/octet-stream, 597B) download --- doc/src/sgml/html/sql-createfunction.html.orig 2013-05-11 12:19:58.579326825 +0200 +++ doc/src/sgml/html/sql-createfunction.html 2013-05-11 12:20:51.510004436 +0200 @@ -389,7 +389,7 @@ ></DT ><DD ><P -> The name of an argument. Some languages (currently only PL/pgSQL) let +> The name of an argument. Some languages (currently only PL/pgSQL and SQL) let you use the name in the function body. For other languages the name of an input argument is just extra documentation, so far as the function itself is concerned; but you can use input argument names
^ permalink raw reply [nested|flat] 8+ messages in thread

* Re: Reference function arguments by name
  2013-05-09 20:46 Reference function arguments by name Erwin Brandstetter <brandstetter@falter.at>
@ 2013-05-11 16:10 ` Tom Lane <tgl@sss.pgh.pa.us>
  2013-06-18 03:15   ` Re: Reference function arguments by name Peter Eisentraut <peter_e@gmx.net>
  2 siblings, 1 reply; 8+ messages in thread

From: Tom Lane @ 2013-05-11 16:10 UTC (permalink / raw)
  To: Erwin Brandstetter <brandstetter@falter.at>; +Cc: pgsql-docs

Erwin Brandstetter <brandstetter@falter.at> writes:
> The manual says here:
> http://www.postgresql.org/docs/current/interactive/sql-createfunction.html

>> The name of an argument. Some languages (currently only PL/pgSQL)
>> let you use the name in the function body. For other languages the

> This has changed in version 9.2. SQL functions can reference the name.

Ah, this comment got missed when updating the docs for that feature.
Fixed, thanks for spotting it!

			regards, tom lane


-- 
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Reference function arguments by name
  2013-05-09 20:46 Reference function arguments by name Erwin Brandstetter <brandstetter@falter.at>
  2013-05-11 16:10 ` Re: Reference function arguments by name Tom Lane <tgl@sss.pgh.pa.us>
@ 2013-06-18 03:15   ` Peter Eisentraut <peter_e@gmx.net>
  2013-06-20 02:35     ` Re: Reference function arguments by name Peter Eisentraut <peter_e@gmx.net>
  0 siblings, 1 reply; 8+ messages in thread

From: Peter Eisentraut @ 2013-06-18 03:15 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Erwin Brandstetter <brandstetter@falter.at>; pgsql-docs

On Sat, 2013-05-11 at 12:10 -0400, Tom Lane wrote:
> Erwin Brandstetter <brandstetter@falter.at> writes:
> > The manual says here:
> > http://www.postgresql.org/docs/current/interactive/sql-createfunction.html
> 
> >> The name of an argument. Some languages (currently only PL/pgSQL)
> >> let you use the name in the function body. For other languages the
> 
> > This has changed in version 9.2. SQL functions can reference the name.
> 
> Ah, this comment got missed when updating the docs for that feature.
> Fixed, thanks for spotting it!

According to https://wiki.postgresql.org/wiki/PL_Matrix, several other
languages support named parameters.  Maybe the parenthetical remark
should be removed altogether.




-- 
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Reference function arguments by name
  2013-05-09 20:46 Reference function arguments by name Erwin Brandstetter <brandstetter@falter.at>
  2013-05-11 16:10 ` Re: Reference function arguments by name Tom Lane <tgl@sss.pgh.pa.us>
  2013-06-18 03:15   ` Re: Reference function arguments by name Peter Eisentraut <peter_e@gmx.net>
@ 2013-06-20 02:35     ` Peter Eisentraut <peter_e@gmx.net>
  0 siblings, 0 replies; 8+ messages in thread

From: Peter Eisentraut @ 2013-06-20 02:35 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Erwin Brandstetter <brandstetter@falter.at>; pgsql-docs

On Mon, 2013-06-17 at 23:15 -0400, Peter Eisentraut wrote:
> On Sat, 2013-05-11 at 12:10 -0400, Tom Lane wrote:
> > Erwin Brandstetter <brandstetter@falter.at> writes:
> > > The manual says here:
> > > http://www.postgresql.org/docs/current/interactive/sql-createfunction.html
> > 
> > >> The name of an argument. Some languages (currently only PL/pgSQL)
> > >> let you use the name in the function body. For other languages the
> > 
> > > This has changed in version 9.2. SQL functions can reference the name.
> > 
> > Ah, this comment got missed when updating the docs for that feature.
> > Fixed, thanks for spotting it!
> 
> According to https://wiki.postgresql.org/wiki/PL_Matrix, several other
> languages support named parameters.  Maybe the parenthetical remark
> should be removed altogether.

Fixed, and also updated the equally wrong claim in 8.4...9.1 that only
PL/pgSQL supports this.




-- 
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs



^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2013-06-20 02:35 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-05-09 20:46 Reference function arguments by name Erwin Brandstetter <brandstetter@falter.at>
2013-05-11 08:13 ` Sian Mountbatten <poenikatu@fastmail.co.uk>
2013-05-11 08:20   ` Erwin Brandstetter <brandstetter@falter.at>
2013-05-11 09:33     ` Sian Mountbatten <poenikatu@fastmail.co.uk>
2013-05-11 10:23 ` Erik Rijkers <er@xs4all.nl>
2013-05-11 16:10 ` Tom Lane <tgl@sss.pgh.pa.us>
2013-06-18 03:15   ` Peter Eisentraut <peter_e@gmx.net>
2013-06-20 02:35     ` Peter Eisentraut <peter_e@gmx.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox