From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.0 required=3.0 tests=BAYES_20 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 13 Oct 92 04:16:15 GMT From: seas.gwu.edu!mfeldman@uunet.uu.net (Michael Feldman) Subject: Re: Does the LRM permit parameter passing by reference? Message-ID: <1992Oct13.041615.26608@seas.gwu.edu> List-Id: In article <1992Oct11.162045.5904@nobeltech.se> dawe@nobeltech.se (Daniel Wenge lin) writes: > >Having read the debate on allowed parameter passing mechanisms, I would >like to follow up with a related question. > >The LRM does (as far as I've understood) allow for an implementation to >skip the "copy-back" of parameters in case an exception is raised preventing >a normal return. What's the impact of this in the real world? Are any >compilers using this optimization feature? > For the case of scalar parameters, what you describe as an "optimization" is in fact REQUIRED by the LRM, sect. 6.2. I quote: "...after NORMAL completion of the subprogram body, if the mode is OUT or IN OUT, the value of the formal parameter IS copied back into the associated actual parameter." I have capitalized NORMAL to indicate that if an exception is propagated from the subprogram, the copyback is NOT done. I have emphasized IS as well - it does not say "may be." For the case of composite parameters (arrays, records), it's best to assume no copyback, because the parameters can (and usually are) passed by reference. This is discussed in the same section of the LRM. Mike Feldman ------------------------------------------------------------------------ Michael B. Feldman co-chair, SIGAda Education Committee Professor, Dept. of Electrical Engineering and Computer Science School of Engineering and Applied Science The George Washington University Washington, DC 20052 USA (202) 994-5253 (voice) (202) 994-5296 (fax) mfeldman@seas.gwu.edu (Internet) "Americans wants the fruits of patience -- and they want them now." ------------------------------------------------------------------------