comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Is 'out' different from 'in out' (Was: Uninitialized "out" parameters)
Date: 1996/07/22
Date: 1996-07-22T00:00:00+00:00	[thread overview]
Message-ID: <Duy5JB.3o@world.std.com> (raw)
In-Reply-To: gauthier-2207961213160001@164.81.60.62


In article <gauthier-2207961213160001@164.81.60.62>,
Michel Gauthier <gauthier@unilim.fr> wrote:
>My intuitive view, and I guess the easier to teach, is that 'out'
>parameters involve
>initialization at the beginning of the subprogram.

I agree that would be the intuitive view, and easier to teach.  It's not
true, though...

On the other hand, it's close enough to being true that if you program
that way, you won't get in trouble.

>... I remember a discussion
>during
>the 9X process about 'out', and a conclusion that there was no longer a
>difference
>between 'out' and 'in out'.

It depends on the type.  For controlled types, there is no difference
between 'out' and 'in out'.

>... Of course, I do not assert that all 83 compilers did
>behave the intuitive way.

Well, it's not a *compiler* issue -- the RM says it.

>So, I repost the question in another form :
>___is there a difference between 'out' and 'in out' parameters ?___

It depends on the type.  For scalars, yes.  For tagged types, no.  For
untagged records with defaulted components, no.  For unconstrained
arrays, no.  See the RM for the complete rule.

Note that in Ada 83, your intuitive view was not true.  One such case is
when the formal is an unconstrained array.  In that case, the bounds of
the array are passed IN, even if the mode is OUT.  For your intuitive
view to work, Ada would have to have truly dynamic arrays (that is,
arrays that can change size on assignment).  Discriminants are similar
to array bounds.

>Consequent questions are :
>___is an 'out' pointer reset to null when entering the subprogram ?___

No.  It is set to whatever the actual was.

>___is an 'out' controlled object finalised and reinitialised when entering
>the subprogram ?___

No.  (Even in your intuitive view, I don't understand why you say "when
entering".  If controlled types used by-copy semantics, then the formal
would be assigned back to the actual after leaving the subprogram.  At
*that* point, the actual would be finalized, the copy done, the actual
Adjusted, and finally the formal finalized.  Initialize wouldn't be
called.)

>___is an 'out' record with initial values reinitialised when entering the
>subprogram ?___

No.  The rules just prevent it from becoming "deinitialized".

>Finally, ___an AI discussion might be envisaged___. Don't you think so ?

No.  (Well, anybody's allowed to send in a comment, but my opinion is
that the rules should not be changed, and my suspicion is that the ARG
would agree.  Of course, I don't speak for the ARG -- I just have one
vote.)

- Bob




  parent reply	other threads:[~1996-07-22  0:00 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-07-18  0:00 Uninitialized "out" parameters Paul Whittington
1996-07-18  0:00 ` Adam Beneschan
1996-07-18  0:00   ` Robert Dewar
1996-07-19  0:00   ` Pascal Obry
1996-07-19  0:00     ` Peter Hermann
1996-07-19  0:00   ` Samuel Tardieu
1996-07-19  0:00     ` John Herro
1996-07-19  0:00       ` Tucker Taft
1996-07-23  0:00         ` Peter Hermann
1996-07-23  0:00           ` Robert A Duff
1996-07-19  0:00   ` Dale Stanbrough
1996-07-19  0:00     ` James A. Squire
1996-07-19  0:00       ` Adam Beneschan
1996-07-20  0:00       ` Michael Feldman
1996-07-21  0:00         ` Fergus Henderson
1996-07-21  0:00           ` Michael Feldman
1996-07-21  0:00             ` Robert Dewar
1996-07-22  0:00             ` Fergus Henderson
1996-07-23  0:00               ` Michael Feldman
1996-07-23  0:00                 ` Robert Dewar
1996-07-25  0:00                   ` Fergus Henderson
1996-07-24  0:00                 ` Robert A Duff
1996-07-25  0:00                   ` Richard A. O'Keefe
1996-07-24  0:00                 ` Fergus Henderson
1996-07-19  0:00     ` Adam Beneschan
1996-07-18  0:00 ` Robert Dewar
1996-07-19  0:00   ` Peter Amey
1996-07-20  0:00   ` Fergus Henderson
1996-07-20  0:00     ` Robert Dewar
1996-07-21  0:00       ` Fergus Henderson
1996-07-21  0:00         ` Robert Dewar
1996-07-23  0:00           ` Fergus Henderson
1996-07-23  0:00             ` Robert A Duff
1996-07-24  0:00               ` Fergus Henderson
1996-07-24  0:00               ` Fergus Henderson
1996-07-23  0:00           ` Richard A. O'Keefe
1996-07-23  0:00             ` Robert Dewar
1996-07-24  0:00               ` Robert A Duff
1996-07-24  0:00               ` Fergus Henderson
1996-07-24  0:00               ` Fergus Henderson
1996-07-25  0:00               ` Richard A. O'Keefe
1996-07-25  0:00                 ` Robert A Duff
1996-07-23  0:00             ` Robert A Duff
1996-07-24  0:00               ` Richard A. O'Keefe
1996-07-24  0:00                 ` Robert A Duff
1996-07-25  0:00                   ` Richard A. O'Keefe
1996-07-25  0:00                     ` Robert A Duff
1996-07-24  0:00                 ` Theodore E. Dennison
1996-07-25  0:00                 ` Frank Manning
1996-07-25  0:00                   ` Richard A. O'Keefe
1996-07-26  0:00                     ` Frank Manning
1996-07-19  0:00 ` Michel Gauthier
1996-07-21  0:00   ` Robert A Duff
1996-07-19  0:00 ` Peter Amey
1996-07-21  0:00 ` Robert A Duff
1996-07-22  0:00 ` Is 'out' different from 'in out' (Was: Uninitialized "out" parameters) Michel Gauthier
1996-07-22  0:00   ` Tucker Taft
1996-07-22  0:00   ` Robert A Duff [this message]
1996-07-22  0:00     ` Robert Dewar
1996-07-23  0:00 ` Uninitialized "out" parameters John Herro
1996-07-23  0:00   ` Robert Dewar
1996-07-24  0:00     ` Peter Hermann
1996-07-23  0:00   ` Robert A Duff
1996-07-24  0:00     ` Uninitialized variables, Java example Arra Avakian
1996-07-25  0:00       ` Robert A Duff
1996-07-25  0:00       ` Richard A. O'Keefe
1996-07-25  0:00         ` Robert A Duff
1996-07-26  0:00   ` Uninitialized "out" parameters Stephen J Bevan
1996-07-26  0:00     ` Robert A Duff
1996-07-23  0:00 ` Is 'out' different from 'in out' (Was: Uninitialized "out" parameters) Michel Gauthier
1996-07-23  0:00   ` Robert Dewar
1996-07-24  0:00   ` Pascal Obry
1996-07-25  0:00   ` Tucker Taft
1996-07-24  0:00 ` Uninitialized variables, Java example Felaco
replies disabled

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