comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R.Carter" <spam.jrcarter.not@spam.acm.org.not>
Subject: Re: Question on in/out parameters
Date: Sat, 30 Apr 2022 11:38:06 +0200	[thread overview]
Message-ID: <t4j01u$djo$1@dont-email.me> (raw)
In-Reply-To: <85d12db3-e308-46bc-9be6-20b48ebe4fd2n@googlegroups.com>

On 2022-04-30 10:57, reinert wrote:
> 
> I expected an "out" parameter in a procedure to be like declaring the parameter "from scratch" (with actual initial default value). For my compiler (GNAT Community Edition, May 2021) it seems like the out parameters brings in content from the calling procedure. Should it be like this?

Parameters in Ada are either passed by copy or passed by reference, regardless 
of parameter mode. The rules are

* Scalar types are always passed by copy
* Tagged types are always passed by reference
* Limited types are always passed by reference
* All other types are decided by the compiler

For the types that are passed by reference, "in out" and "out" mode are identical.

Vector is a tagged type, so this applies to it.

One can argue that an out-mode parameter of a by-reference type should be 
"reinitialized" before use, but the Ada-9X revision decided not to require this.

-- 
Jeff Carter
"Hello! Smelly English K...niggets."
Monty Python & the Holy Grail
08

  reply	other threads:[~2022-04-30  9:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-30  8:57 Question on in/out parameters reinert
2022-04-30  9:38 ` Jeffrey R.Carter [this message]
2022-04-30 11:30   ` reinert
2022-05-01  7:50     ` J-P. Rosen
2022-05-02 21:35 ` Randy Brukardt
replies disabled

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