Hi Mike,
Sorry for the delay, this discussion was not finished completely.
"> The value of x is undefined after the call, right? So
> calling a function with an out parameter is the equivalent to
> using an inout parameter, and filling the actual paramter
> with undefined values before the call. Correct?"
Taking the definition of out parameters literally, yes, this should happen. On the other hand, note 1 of 5.4.1 says:
"NOTE 1: Although out parameters can be read within the parameterized object, they do not inherit the value of their actual parameter; i.e. they should be set before they are read."
This can be understood that a value _shall_ be assigned to the formal parameter within f(), before returning from the function.
We have just discussed the issue in STF 349 and the conclusion was that we shall check the semantics of out parameterization, remove any possible ambiguity and increase clarity of the text if necessary. I wrote the following CR on the issue:
t-ort.etsi.org/view.php?id=3946
BR, Gyorgy
>
Original Message
> From: active_ttcn3 : mts stf133 ttcn version 3 - active
> members only [
This email address is being protected from spambots. You need JavaScript enabled to view it.] On Behalf Of Michael Sperber
> Sent: Thursday, 31 July, 2008 8:08 AM
> To:
This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Re: Out parameters vs. subtype restrictions
>
> György Réthy <
This email address is being protected from spambots. You need JavaScript enabled to view it.> writes:
>
> > Technically the same answer is also given in Part-1; see
> note 2 to the
> > definition of inout parameterization: "inout
> parameterization: kind of
> > parameterization where the value of the actual parameter is
> bound to
> > the formal parameter when the parameterized object is
> invoked and the
> > value of the formal parameter is passed back to the actual
> parameter,
> > when the invoked object completes NOTE 1: Inout parameters
> can be used
> > for functions, altsteps, and test cases only. NOTE 2: All
> changes to
> > the arguments within the invoked object have effect on the
> arguments
> > as seen by the invoking object."
>
> Right. I was mainly wondering about the interaction with subtyping.
> Now, with out parameters, I was puzzled by this wording in
> the standard (clause 5.4.1):
>
> >> Although out parameters can be read within the
> parameterized object,
> >> they do not inherit the value of their actual parameter; i.e. they
> >> should be set before they are read.
>
> Now I understand sharing is preserved even by out parameters.
> So, if I do this:
>
> function f(out integer a) {
> // nothing
> }
>
> ...
> var integer x := 5;
> f(x);
> ...
>
> The value of x is undefined after the call, right? So
> calling a function with an out parameter is the equivalent to
> using an inout parameter, and filling the actual paramter
> with undefined values before the call. Correct?
>
> --
> Regards,
> Mike
>