Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ub4w7-0001aE-J2 for pgsql-docs@arkaria.postgresql.org; Sat, 11 May 2013 08:13:48 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Ub4w6-0002Em-Sk for pgsql-docs@arkaria.postgresql.org; Sat, 11 May 2013 08:13:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ub4w5-0002Eg-M2 for pgsql-docs@postgresql.org; Sat, 11 May 2013 08:13:46 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ub4vx-0008FI-7S for pgsql-docs@postgresql.org; Sat, 11 May 2013 08:13:45 +0000 Received: from compute1.internal (compute1.nyi.mail.srv.osa [10.202.2.41]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 2A6662059D; Sat, 11 May 2013 04:13:35 -0400 (EDT) Received: from frontend2.nyi.mail.srv.osa ([10.202.2.161]) by compute1.internal (MEProxy); Sat, 11 May 2013 04:13:35 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.co.uk; h= message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; s=mesmtp; bh=4/MnwszBhrLqTc/zbMoCQht2 8Ec=; b=k/5Sk4HPNemLjDHqs9hnl+RaLqkeA451iQ4wo/Mf3XG9xhlPc1DD1ENA 6rsh4pGlZJaCs4HmMBnXnxOtEGRHJmb2WDBWeJibcTIGXvrX8spi7ZjxU0iT172q QZt1XV//UdWoXTVkLcHnyq3lgPxOp59rGWebF9ij8s79ydiKMkA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:date:from:mime-version:to :subject:references:in-reply-to:content-type; s=smtpout; bh=4/Mn wszBhrLqTc/zbMoCQht28Ec=; b=orBFydaX/aHhsp5Yjdcn3wsYXradIlpyK1V+ +0FRkwaqZb/4K4dEwPI8Kg9RYNr9/RPPe/zZdf2KGGTD2QSZiA4eluSgNnlgXi4c bNreWIBn1EbEmtgV+3FgFR7ufmm/XyqNmjwVqwgP1qIHKNkEb1qLBneq0DYe7XX9 H1KYPRk= X-Sasl-enc: x9GHJN2pm0NygJIVczkJadfES9MAI+uk182VCkngvD+o 1368260014 Received: from [192.168.11.21] (unknown [78.146.152.197]) by mail.messagingengine.com (Postfix) with ESMTPA id 498FC200183; Sat, 11 May 2013 04:13:34 -0400 (EDT) Message-ID: <518DFDAC.2060909@fastmail.co.uk> Date: Sat, 11 May 2013 09:13:32 +0100 From: Sian Mountbatten User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 MIME-Version: 1.0 To: Erwin Brandstetter , pgsql-docs@postgresql.org Subject: Re: Reference function arguments by name References: <518C0B2B.9040909@falter.at> In-Reply-To: <518C0B2B.9040909@falter.at> Content-Type: multipart/alternative; boundary="------------050206000608010700090407" X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org This is a multi-part message in MIME format. --------------050206000608010700090407 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 >> ). >> 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 --------------050206000608010700090407 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit
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). 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


--------------050206000608010700090407--