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: 9 Oct 92 14:11:46 GMT From: van-bc!cs.ubc.ca!destroyer!caen!uflorida!travis.csd.harris.com!ada1!danr@ ucbvax.Berkeley.EDU (Dan Rittersdorf) Subject: Re: Does the LRM permit parameter passing by reference? Message-ID: <1b43v2INN43n@travis.csd.harris.com> List-Id: In article <1992Oct9.023807.20641@beaver.cs.washington.edu> simonson@cs.washing ton.edu (Kevin Simonson) writes: > I was under the impression that Ada made local copies of parameter >values when a procedure was called. However my Verdix compiler apparently >does calls by reference when the call is for a string value, as demonstrat- >ed by the script file below. Notice how the parameter "COPY" (which Ada >won't allow code to alter inside the procedure) changes its value from the >first "put_line" to the second. > > Is it legal for Ada to allow this parameter to change in the middle of >the procedure, or have I found a bug? > > ---Kevin Kevin, RM 6.2(7) addresses this issue. For arrays, records, or task types, the LRM gives the implementation the option of pass by reference or value. The Verdix compiler and derivatives pass arrays by reference, and since strings are arrays of character, it is also passed by reference. Note that for scalar types (integers, enumerations, floating and fixed point types) the LRM explicitly requires pass by value. You can count on it for these types. Note also that any program that depends on the parameter passing mechanism (for arrays, records, or task types) is declared "erroneous" by the LRM, which means that the program is in error, but the compiler is not required to detect this dependence and issue an error message. -- -danr ______________________________________________________________________________ Dan Rittersdorf danr@travis.ssd.csd.harris.com Harris Corporation, Computer Systems Division, Fort Lauderdale, FL 33309 ______________________________________________________________________________ -Won by One "Sync or be Sunc"