comp.lang.ada
 help / color / mirror / Atom feed
From: reinert <reinkor@gmail.com>
Subject: Re: Question on in/out parameters
Date: Sat, 30 Apr 2022 04:30:14 -0700 (PDT)	[thread overview]
Message-ID: <fb8e503f-70a3-44a3-867e-132191f25762n@googlegroups.com> (raw)
In-Reply-To: <t4j01u$djo$1@dont-email.me>

Thanks for sorting out my confusion. 

So there is no difference between "in", "in out" and "out" for Vectors except that the compiler protests if I try to change an "in parameter" in the actual subroutine/function?

reinert


lørdag 30. april 2022 kl. 11:38:08 UTC+2 skrev Jeffrey R.Carter:
> 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 11:30 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
2022-04-30 11:30   ` reinert [this message]
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