From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Uninitialized out parameters. Date: Wed, 6 Apr 2016 15:47:49 -0500 Organization: JSA Research & Innovation Message-ID: References: <3be79ab3-ebc7-4169-9713-d50349662403@googlegroups.com> <70a76f87-51a9-4e77-9fa0-79714f9c0ba7@googlegroups.com> NNTP-Posting-Host: rrsoftware.com X-Trace: loke.gir.dk 1459975670 529 24.196.82.226 (6 Apr 2016 20:47:50 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Wed, 6 Apr 2016 20:47:50 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-RFC2646: Format=Flowed; Response Xref: news.eternal-september.org comp.lang.ada:30017 Date: 2016-04-06T15:47:49-05:00 List-Id: "G.B." 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.