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:a37:c44:0:b0:69f:81cb:1d6a with SMTP id 65-20020a370c44000000b0069f81cb1d6amr2378579qkm.494.1651318215095; Sat, 30 Apr 2022 04:30:15 -0700 (PDT) X-Received: by 2002:a25:e90a:0:b0:648:a3da:b52b with SMTP id n10-20020a25e90a000000b00648a3dab52bmr3272468ybd.100.1651318214913; Sat, 30 Apr 2022 04:30:14 -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 04:30:14 -0700 (PDT) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=84.209.88.37; posting-account=bPTmZAoAAAC_6HP9XLKB9aAAxBa6BuOR NNTP-Posting-Host: 84.209.88.37 References: <85d12db3-e308-46bc-9be6-20b48ebe4fd2n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Question on in/out parameters From: reinert Injection-Date: Sat, 30 Apr 2022 11:30:15 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:63788 List-Id: Thanks for sorting out my confusion.=20 So there is no difference between "in", "in out" and "out" for Vectors exce= pt that the compiler protests if I try to change an "in parameter" in the a= ctual subroutine/function? reinert l=C3=B8rdag 30. april 2022 kl. 11:38:08 UTC+2 skrev Jeffrey R.Carter: > On 2022-04-30 10:57, reinert wrote:=20 > >=20 > > I expected an "out" parameter in a procedure to be like declaring the p= arameter "from scratch" (with actual initial default value). For my compile= r (GNAT Community Edition, May 2021) it seems like the out parameters bring= s in content from the calling procedure. Should it be like this? > Parameters in Ada are either passed by copy or passed by reference, regar= dless=20 > of parameter mode. The rules are=20 >=20 > * Scalar types are always passed by copy=20 > * Tagged types are always passed by reference=20 > * Limited types are always passed by reference=20 > * All other types are decided by the compiler=20 >=20 > For the types that are passed by reference, "in out" and "out" mode are i= dentical.=20 >=20 > Vector is a tagged type, so this applies to it.=20 >=20 > One can argue that an out-mode parameter of a by-reference type should be= =20 > "reinitialized" before use, but the Ada-9X revision decided not to requir= e this.=20 >=20 > --=20 > Jeff Carter=20 > "Hello! Smelly English K...niggets."=20 > Monty Python & the Holy Grail=20 > 08