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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a00006d3c4735d70 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-01-26 12:55:10 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!nnx.oleane.net!oleane!frmug.org!freenix!enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: "Alexandre E. Kopilovitch" Newsgroups: comp.lang.ada Subject: Re: In-Out Parameters for functions Date: Mon, 26 Jan 2004 23:19:49 +0300 (MSK) Organization: Cuivre, Argent, Or Message-ID: References: NNTP-Posting-Host: lovelace.ada-france.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: melchior.cuivre.fr.eu.org 1075148420 30470 80.67.180.195 (26 Jan 2004 20:20:20 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Mon, 26 Jan 2004 20:20:20 +0000 (UTC) To: comp.lang.ada@ada-france.org Return-Path: In-Reply-To: ; from "Dmitry A. Kazakov" at Mon, 26 Jan 2004 11:17:22 +0100 X-Mailer: Mail/@ [v2.44 MSDOS] X-Virus-Scanned: by amavisd-new-20030616-p5 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.3 Precedence: list List-Id: Gateway to the comp.lang.ada Usenet newsgroup List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:4838 Date: 2004-01-26T23:19:49+03:00 Dmitry A. Kazakov wrote: > >Therefore, IN OUT parameters in functions will not be worse than the ability > >of functions to change global variables if we forbid use of such functions in > >expressions, that is: > > > > If at least one parameter of a function is in IN OUT mode then the function > > cannot be used in a compound expression. This function's call must always > > constitute the whole RHS of an assignment. > > > >or less restrictive rule: > > > > If at least one parameter of a function is in IN OUT mode then in any > > expression in which this function is called all other calls may be for > > parameterless functions only. > > What about: > > F(X) and then F(X) Naturally, forbidden. Perhaps the wording of my (above) "less restrictive rule" was not good enough, but I meant that "all other calls" includes other calls of the mentioned function (which has an IN OUT parameter), and that the meaning is entirely static, not dynamic. So, probably at least one correction should be made in this rule - replacing "calls" by "references": If at least one parameter of a function is in IN OUT mode then in any expression in which this function is called all other references may be for parameterless functions only. Well, I leave the exact wording of the rule to native English speakers -;) . > The rule, if any, should prevent using an object in IN OUT mode in an > expression where the evaluation order is not specfied by the language. Yes, certainly. And I'd forbid that even if that order IS specified but may be non-obvious... actually I'd forbid that in all cases where that order can matter at all - for anything. > Looks much like the aliasing problem: > > procedure Foo (X, Y : in out Object) is > begin > X := F(X) + F(Y); -- Is this legal? > Foo (X, X); -- And this? > end Foo; Perhaps legal, but awfully wrong -;) Alexander Kopilovitch aek@vib.usr.pu.ru Saint-Petersburg Russia