f



Re: "out" and "in out"

"no reliable initial value" means, you cannot rely on the value, but it may have a value. This depends on the parameter passing mechanism, which is _not_ related to the parameter mode (contrary to what many people think).

So the parameter mode is there (nearly) solely for the information of the reader. The parameter passing mechanism for all kinds of parameters is defined in the RM. There are parameters passed by copy (in and out), by reference; for some it is explicitly left undefined.

In your case, the passing mechanism is by reference, so you get what you get. But don't rely on this, rely only on the mode, i.e. the parameter st is undefined upon entering the procedure modify, so when you only write component 2, upon return, only component 2 has been written. Under slight variations, the result of your code might be <garbage character>U<garbage character>.

Another thing: Don't rely upon s1'First = 1. Component 2 might not exist. You could call modify like so:

X: String (25..30);
modify (X);

Now s1(2) inevitably will raise Constraint_Error.
____________________________________________________
Aufnehmen, abschicken, nah sein - So einfach ist 
WEB.DE Video-Mail: http://freemail.web.de/?mc=021200

0
AdaMagica (30)
7/26/2004 10:54:04 AM
comp.lang.ada 8774 articles. 2 followers. Post Follow

1 Replies
1548 Views

Similar Articles

[PageSpeed] 20

"Christoph Karl Walter Grein" <AdaMagica@web.de> wrote:
>
> In your case, the passing mechanism is by reference, so you get what you
get. But don't rely on this, rely only on the mode, i.e. the parameter st is
undefined upon entering the procedure modify, so when you only write
component 2, upon return, only component 2 has been written. Under slight
variations, the result of your code might be <garbage character>U<garbage
character>.
>
> Another thing: Don't rely upon s1'First = 1. Component 2 might not exist.

While you can't rely on the initial _value_ of the parameter, you _can_ rely
on getting accurate information about it from its attributes.

As Christoph notes, while s1'First may not be 1, s1'First will correctly
reflect the argument's index's first value, similarly for s1'Last and
s1'Length--in this case, 3. And so on for other relevant attributes.

Marc A. Criley
McKae Technologies
www.mckae.com


0
mcNOSPAM (258)
7/26/2004 2:16:46 PM
Reply: