comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Uninitialized out parameters.
Date: Wed, 6 Apr 2016 15:47:49 -0500
Date: 2016-04-06T15:47:49-05:00	[thread overview]
Message-ID: <ne3slm$gh$1@loke.gir.dk> (raw)
In-Reply-To: ne2ngo$uea$1@dont-email.me

"G.B." <bauhaus@futureapps.invalid> wrote in message 
news:ne2ngo$uea$1@dont-email.me...
> On 06.04.16 10:19, ahlan@marriott.org wrote:
...
>> But even that is not the point I'm trying to make.
>> I am suggesting that it ought not to be possible to define a null 
>> procedure
>> that has out parameters without some form of warning being issued.
>
> I think the usual answer is that the compiler is not a mind
> reader and the best you could get is a warning. Who knows?
> Maybe the technical requirements are such that the programmer
> uses a procedure like Test as a placeholder, maybe its existence
> is dictated by an abstract type, maybe a null procedure really
> should do nothing at all, which includes not touching V.

I agree with Georg here. It *seems* like checks like the one Ahlan is 
suggesting are a good idea, until you trip over one. (The check in Ada that 
every function have at least one return is a similar idea, which causes no 
end of trouble.)

I can think of at least three reasons why one might write a null procedure 
with an out parameter:
(1) The null procedure body is a TBD placeholder. It will be replaced with a 
real body at some future point, but we still want to compile.
(2) The out parameter isn't used for some implementations. This often comes 
up when there are multiple parameters. (We ran into this commonly in Claw, 
although we usually used in out parameters in such cases to avoid 
de-initializing objects.) The situation is that some objects need additional 
return information and others don't:
     procedure Do_Something (Obj : in out Object; Result : in out 
Result_Type; Extra_Info : out Natural);
Extra_Info is only used if Result has a particular value.
(3) The null procedure is used in an interface. In that case, giving a body 
isn't possible.

I think you could make a case that all of these are better written some 
other way, but that's irrelevant, in that each of these could happen in real 
code, and making a legality check would break that code. (Thus, making it 
illegal would probably be considered too incompatible for future Ada, unless 
of course we discovered some semantic problem that doing that would fix.)

The Ada Standard has nothing to say about warnings (other than for pragmas). 
Perhaps some future version of Ada will change that, but as of now, every 
warning is implementation-defined, and thus it they don't have anything to 
do with the language. (That is, talk to your vendor about warnings.)

                                      Randy.



  parent reply	other threads:[~2016-04-06 20:47 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-05 12:02 Uninitialized out parameters ahlan
2016-04-05 13:17 ` rieachus
2016-04-05 14:07   ` ahlan
2016-04-06  9:45     ` Mark Lorenzen
2016-04-06 21:01       ` Jeffrey R. Carter
2016-04-07  7:10       ` ahlan
2016-04-05 16:19 ` G.B.
2016-04-06  8:19   ` ahlan
2016-04-06 10:17     ` G.B.
2016-04-06 11:44       ` Dennis Lee Bieber
2016-04-06 20:41         ` Niklas Holsti
2016-04-06 20:54         ` Randy Brukardt
2016-04-06 20:47       ` Randy Brukardt [this message]
2016-04-06 21:01         ` Randy Brukardt
2016-04-06 21:22           ` Dmitry A. Kazakov
2016-04-07  7:27             ` Randy Brukardt
2016-04-06 11:37 ` AdaMagica
2016-04-06 13:44   ` ahlan
2016-04-06 14:09     ` Mark Lorenzen
2016-04-06 14:10     ` G.B.
2016-04-06 20:53     ` Stefan.Lucks
2016-04-06 21:03       ` Randy Brukardt
2016-04-06 21:12       ` Niklas Holsti
2016-04-06 21:30       ` Randy Brukardt
2016-04-07  9:56         ` Stefan.Lucks
2016-04-07 16:08           ` AdaMagica
2016-04-07 23:02             ` Randy Brukardt
2016-04-08  7:32               ` Dmitry A. Kazakov
2016-04-07  7:52       ` Georg Bauhaus
  -- strict thread matches above, loose matches on Subject: below --
1996-07-29  0:00 W. Wesley Groleau (Wes)
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     ` Adam Beneschan
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-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               ` Fergus Henderson
1996-07-24  0:00               ` Fergus Henderson
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-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-23  0:00 ` 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-26  0:00   ` Stephen J Bevan
1996-07-26  0:00     ` Robert A Duff
replies disabled

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