From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:a05:622a:1750:b0:2f3:6453:b382 with SMTP id l16-20020a05622a175000b002f36453b382mr2689241qtk.396.1651309057397; Sat, 30 Apr 2022 01:57:37 -0700 (PDT) X-Received: by 2002:a0d:ffc3:0:b0:2eb:2327:3361 with SMTP id p186-20020a0dffc3000000b002eb23273361mr3175570ywf.36.1651309057241; Sat, 30 Apr 2022 01:57:37 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 30 Apr 2022 01:57:37 -0700 (PDT) Injection-Info: google-groups.googlegroups.com; posting-host=84.209.88.37; posting-account=bPTmZAoAAAC_6HP9XLKB9aAAxBa6BuOR NNTP-Posting-Host: 84.209.88.37 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <85d12db3-e308-46bc-9be6-20b48ebe4fd2n@googlegroups.com> Subject: Question on in/out parameters From: reinert Injection-Date: Sat, 30 Apr 2022 08:57:37 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:63786 List-Id: Hello, I expected an "out" parameter in a procedure to be like declaring the param= eter "from scratch" (with actual initial default value). For my compiler (G= NAT Community Edition, May 2021) it seems like the out parameters brings in= content from the calling procedure. Should it be like this? Below is a test program to illustrate. reinert with Ada.Containers; use Ada.Containers; with Ada.Containers.Vectors; with Ada.Text_IO; use Ada.Text_IO; procedure test2 is package Integer_Vectors is new Ada.Containers.Vectors (Index_Type =3D> Natural, Element_Type =3D> Integer); use Integer_Vectors; V : Vector :=3D 10 & 20; procedure rk_in_out(W : in out Vector) is begin W.Append(30); W.Append(40); end rk_in_out; procedure rk_out(W : out Vector) is begin W.Clear; -- I expected this statement to be redundant since W is "out= parameter" (try to remove it and see if results remain the same.)? W.Append(30); W.Append(40); end rk_out; begin New_Line; Put ("First V : "); for e of V loop Put(e'Image & " "); end loop; rk_in_out(W =3D> V); New_Line; Put ("Second V : "); for e of V loop Put(e'Image & " "); end loop; rk_out(W =3D> V); New_Line; Put ("Third V : "); for e of V loop Put(e'Image & " "); end loop; end test2;