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 callingprocedure. Should it be like this?
On 2022-04-30 10:57, reinert wrote:procedure. Should it be like this?
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
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
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?
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?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 374 |
Nodes: | 16 (2 / 14) |
Uptime: | 08:02:13 |
Calls: | 7,975 |
Calls today: | 4 |
Files: | 13,017 |
Messages: | 5,819,862 |