comp.lang.ada
 help / color / mirror / Atom feed
From: simonson@beaver.cs.washington.edu  (Kevin Simonson)
Subject: Does the LRM permit parameter passing by reference?
Date: 9 Oct 92 02:38:07 GMT	[thread overview]
Message-ID: <1992Oct9.023807.20641@beaver.cs.washington.edu> (raw)

     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

ph^guru} cat reference_demo_p.a
with text_io;

procedure REFERENCE_DEMO_P
is

   ORIGINAL : string(1..3);

   procedure DEMO_P (COPY : string)
   is

   begin

      text_io.put_line (COPY);
      ORIGINAL(1..COPY'length) := COPY;
      text_io.put_line (COPY);

   end DEMO_P;

begin

   ORIGINAL := "abc";
   DEMO_P (ORIGINAL(2..3));

end REFERENCE_DEMO_P;
ph^guru} reference_demo_p
bc
cc
ph^guru} exit
ph^guru} 
script done on Thu Oct  8 08:53:41 1992

             reply	other threads:[~1992-10-09  2:38 UTC|newest]

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

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