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=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.ams3.giganews.com!border2.nntp.ams3.giganews.com!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!rt.uk.eu.org!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: Tue, 07 May 2013 05:59:49 +0200 Organization: Ada @ Home Message-ID: References: <7704abab-86f2-4edc-ad4b-b3d4e70004fb@googlegroups.com> NNTP-Posting-Host: /5uFWkegPs0CGJSoRIUiIw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.15 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 X-Original-Bytes: 3157 Date: 2013-05-07T05:59:49+02:00 List-Id: Le Sun, 05 May 2013 12:24:50 +0200, Niklas Holsti = a =C3=A9crit: > On 13-05-04 02:29 , Randy Brukardt wrote: > >> I agree that named notation should include the direction of the = >> parameter, >> but again its way too late to fix. The best syntax would have been >> Proc (In_Param =3D> A, Out_Param <=3D B, In_Out_Param <=3D> C); >> but unfortunately "<=3D" is used for less-than-or-equals and trying t= o = >> use it >> in this context would be ambiguous. >> >> So the best practical syntax would be: >> Proc (In_Param -> A, Out_Param <- B, In_Out_Param <-> C); > > How about reusing the mode keywords: > > Proc ( > In_Param =3D> in A, > Out_Param =3D> out B, > In_Out_Param =3D> in out C); > As another option if you are not afraid about a lot of restrictions, the= re = is one which won't make parameters modes visible, but which will surely = = catch any erroneous assumptions on these, due to an assertion on the = effect of calling it, failing sooner or later: -- SPARK way to solve the issue -- and to make explicit what it do. procedure P (A : out T; B : in out T; C : in T); --# derives --# A from B, C & --# B from B, C ; As a bonus, this could even catch far more errors than simply reminding = = parameter modes :-P =E2=80=A6 but forget about generic packages [1], sub= types [2] = and many other things. [1]: library level generic sub=E2=80=91programs is OK, but this has the = = implication a generic cannot defines types, constants, etc. [2]: the last time I tried it, only type=E2=80=91new was allowed, not su= re if it's = still the same now; may check later. -- = =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