comp.lang.ada
 help / color / mirror / Atom feed
From: seas.gwu.edu!mfeldman@uunet.uu.net  (Michael Feldman)
Subject: Re: Does the LRM permit parameter passing by reference?
Date: 13 Oct 92 04:16:15 GMT	[thread overview]
Message-ID: <1992Oct13.041615.26608@seas.gwu.edu> (raw)

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."
------------------------------------------------------------------------

             reply	other threads:[~1992-10-13  4:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-10-13  4:16 Michael Feldman [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-10-11 16:20 Does the LRM permit parameter passing by reference? eru.mt.luth.se!lunic!sunic!nobeltech!dawe
1992-10-09 18:12 Michael Feldman
1992-10-09 14:11 Dan Rittersdorf
1992-10-09  2:38 Kevin Simonson
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox