comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@cs.nyu.edu (Robert Dewar)
Subject: Re: Is 'out' different from 'in out' (Was: Uninitialized "out" parameters)
Date: 1996/07/23
Date: 1996-07-23T00:00:00+00:00	[thread overview]
Message-ID: <dewar.838163199@schonberg> (raw)
In-Reply-To: gauthier-2307961037570001@164.81.60.62


Michael said

"They all confirm what I was not entirely sure to understand correctly.
There is no essential difference between 'out' and 'in out' parameters,
and it is probably worth considering them to be the same thing.

IMHO, it was a mistake of the 9X design. It's too late to repair.

Possible useful style rule : avoid 'out' parameters, since they
are error-prone, and prefer 'in out'."



First, they confirmed no such thing. Out and in-out are VERY different
for scalars, as several of the posts emphasized. In particular, using
in-out unnecessarily causes the caller to generate unncecessary code to
initialze the input value. I would actually consider a program that
passed an uninitialized variable as an in parmeter to be violating
the spec of a subprogram. 

As for suggesting a style rule to avoid 'out' parameters, I strongly
object quite independently of the above concerns.

The use of OUT as a mode is a clear and important part of the documentation
of subprograms. In general we document the input-output behavior of a
procedure. The IN and IN OUT parameters describe the input requirements,
the OUT and IN OUT parameters describe the outputs. It is a bad confusion
to take an OUT parameter and convert it to IN OUT.

As for out parameters being error-prone, this seems nonsense to me. Are
you still worrying about the possibility of the variable being uninitialized
on entry? Well making it an in out parameter doesn't change that, because
an uninitialized variable can be passed in. However, it DOES stop the
compiler from issuing some obvious warnings. SUppose we have

   procedure x (a : out integer) is
   begin
	a := a + 1;
        ...

now any reasonable compiler will give a warning. But if you gratuitously
change the parameter to in out, no warning is possible.

Of course it is possible that the compiler might be able to warn you
about passing uninitialized variables as inputs to this procedure. However,
if this is a parameter which really conceptually is an out parameter, which
you have gratuitously changed to in out, then these warnings are of course
conceptually incorrect.

This is definitely NOT an idea that flies!





  reply	other threads:[~1996-07-23  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   ` 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-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   ` Pascal Obry
1996-07-19  0:00     ` Peter Hermann
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           ` Richard A. O'Keefe
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-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           ` 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-19  0:00 ` Peter Amey
1996-07-19  0:00 ` Michel Gauthier
1996-07-21  0:00   ` Robert A Duff
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
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 [this message]
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