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-29 12:42:44 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!proxad.net!usenet-fr.net!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: Thu, 29 Jan 2004 23:25:27 +0300 (MSK) Organization: Cuivre, Argent, Or Message-ID: References: <5ad0dd8a.0401290422.23e3e059@posting.google.com> 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 1075407973 17548 80.67.180.195 (29 Jan 2004 20:26:13 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Thu, 29 Jan 2004 20:26:13 +0000 (UTC) To: comp.lang.ada@ada-france.org Return-Path: In-Reply-To: <5ad0dd8a.0401290422.23e3e059@posting.google.com>; from Wojtek Narczynski at 29 Jan 2004 04:22:55 -0800 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:5064 Date: 2004-01-29T23:25:27+03:00 Wojtek Narczynski wrote: >How about you add 'return' and 'access' to procedures instead? At this point I can't resist the temptation to quote my own posting to Ada-Comment (November 2002) along with the brief discussion, which followed (I removed the poster's name from all replies). Here it is: ============================================================================= I'm not going to restate the arguments, but just want to know what is bad or wrong in the following solution for a problem: ---------- Let us introduce new mode for formal parameter: RETURN mode. This RETURN mode is the same as OUT mode except the following rules: in the procedure specification: 1) only the first parameter of the procedure may be in RETURN mode; 2) IN mode is incompatible with RETURN mode, that is, there is no IN RETURN mode. in the procedure body: if the formal parameter in RETURN mode is of indefinite type then the attributes, which depend on undefined properties (for example, 'First, 'Length, etc.) cannot be used for that parameter. in a procedure call: 1) a procedure with the first parameter in RETURN mode may be invoked as function (without argument for the first parameter); 2) normal (that is, procedural) call for that procedure is also available; in that call RETURN mode is treated as OUT mode. ---------- -------------------------------------------------------------------------- This is a warmed over version of the DEC Valued_Procedure pragmas ... -------------------------------------------------------------------------- >This is a warmed over version of the DEC Valued_Procedure pragmas ... Well, of course, and GNAT implements those pragmas also. But this similarity is a good thing, as it certifies for a proven mechamism. The difference is that it is not an implementation-defined pragma(s), but a straight language form. -------------------------------------------------------------------------- > Well, of course, and GNAT implements those pragmas also. But this similarity > is a good thing, as it certifies for a proven mechamism. The difference is that > it is not an implementation-defined pragma(s), but a straight language form. Well I regard both the pragmas and the AK proposed substitute as too junky to consider. If you want IN OUT parameters for functions, just allow them. The DEC pragmas are merely a kludgy device to get around the absence of a needed feature. I don't see the AK proposal here as any improvement over the pragmas. -------------------------------------------------------------------------- > Let us introduce new mode for formal parameter: RETURN mode. > This RETURN mode is the same as OUT mode except the following rules: >... This basic idea might serve as a solution to the "constructor function" problem that Bob Duff is working in AI-318. The problem with the existing proposals for that were that the methods of getting a name for the return result were just plain weird - objects with boatloads of restrictions. It may be easier to define the needed restrictions in terms of a parameter mode. ... -------------------------------------------------------------------------- ============================================================================= Hope this helps -;) . Alexander Kopilovitch aek@vib.usr.pu.ru Saint-Petersburg Russia