From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,3867e2f73fa21ec X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 X-Received: by 10.180.75.133 with SMTP id c5mr2932844wiw.2.1367666059392; Sat, 04 May 2013 04:14:19 -0700 (PDT) Path: p18ni66831wiv.0!nntp.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!85.12.40.138.MISMATCH!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!border2.nntp.dca.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed.news.ucla.edu!nrc-news.nrc.ca!News.Dal.Ca!news.litech.org!news2.arglkargh.de!news.mixmin.net!aioe.org!.POSTED!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: Ada 2012: In-out parameters for functions Date: Wed, 01 May 2013 21:04:03 +0200 Organization: Ada @ Home Message-ID: References: <7704abab-86f2-4edc-ad4b-b3d4e70004fb@googlegroups.com> NNTP-Posting-Host: nS0pckIoQAtdrQ+ei+VCFQ.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.15 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable Date: 2013-05-01T21:04:03+02:00 List-Id: Le Wed, 01 May 2013 18:28:07 +0200, a =C3=A9crit: > Why does Ada 2012 have in-out parameters for functions? > > Quote from the book 'Ada 2005 Rationale' (page 4): "[..] Indeed many = > other changes were rejected as really unnecessary. These include old = > chestnuts such as in out and out parameters for functions (ugh), [..]"= . > > So, when do I use functions or procedures. Functions have return value= s. = > Any other differences? > > - Dennis This is just personal opinion, I don't speak for anyone else: I did not enjoy neither the out mode parameters for functions in Ada 201= 2, = but after some though, had the conviction it's not that much bad. On one hand, you were already able to have functions with side effects = prior to Ada 2012, which is even worse than out parameters. If a functio= n = modifies an outer level variable which is visible from its body, and tha= t = variable may be interpreted later from outside of the body of this = function, that's less clear than using an out parameter. Then, there is what a function do and how it is implemented. Out mode = parameters is just implementation after=E2=80=91all, and sometime, you m= ay really = need out parameters to complete the purpose of a rally pure function: Ad= a = function does not returns tuples like SML's functions may do, and to = achieve this in Ada, you need out parameters, or else you may have to = define multiple types everywhere (if all elements of the tuples have = different types, you do not really need to define a record type for that= , = as there is no way to take one element for another). Semantic is one thing, implementation is another. And if you want = functional programming in Ada, you need out parameters. In/out (both way) parameters may be another story, and may more suggest = = this is a procedure and not a function, but still the same: semantic is = = one thing, implementation is another, and there is not always an exact = match of one on the other. -- = =E2=80=9CSyntactic sugar causes cancer of the semi-colons.=E2=80=9D [1] =E2=80=9CStructured Programming supports the law of the excluded muddle.= =E2=80=9D [1] [1]: Epigrams on Programming =E2=80=94 Alan J. =E2=80=94 P. Yale Univers= ity